Skip to content

Commit 9d02671

Browse files
authored
Merge pull request #6 from SyncfusionExamples/ES-975464
ES-975464 - Resolve the ReadMe file length issue in this sample repository
2 parents 39947c2 + b00d72f commit 9d02671

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,59 @@
1-
# How to customize style of the scroll viewer in WPF DataGrid (SfDataGrid)?
1+
# How to Customize Style of the ScrollViewer in WPF DataGrid?
22

3-
This example illustrates how to customize style of the scroll viewer in [WPF DataGrid](https://www.syncfusion.com/wpf-ui-controls/datagrid) (SfDataGrid).
3+
This example illustrates how to customize style of the [ScrollViewer](https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.scrollviewer?view=netframework-4.7.2) in [WPF DataGrid](https://www.syncfusion.com/wpf-ui-controls/datagrid) (SfDataGrid).
44

5-
You can customize the style of scroll viewer in which WPF DataGrid (SfDataGrid) is loaded. But while scrolling using mouse wheel, the header will also be scrolled with records. You can overcome this behavior by binding the `CanContentScroll` property of `ScrollViewer`.
5+
You can customize the style of **ScrollViewer** in which DataGrid is loaded. But while scrolling using mouse wheel, the header will also be scrolled with records. You can overcome this behavior by binding the [CanContentScroll](https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.scrollviewer.cancontentscroll?view=netframework-4.7.2#System_Windows_Controls_ScrollViewer_CanContentScroll) property of **ScrollViewer**.
66

7-
KB article - [How to customize style of the scroll viewer in WPF DataGrid (SfDataGrid)?](https://www.syncfusion.com/kb/9768/how-to-customize-style-of-the-scroll-viewer-in-wpf-datagrid-sfdatagrid)
7+
``` xml
8+
<Window.Resources>
9+
<Style TargetType="ScrollViewer">
10+
<Setter Property="Template">
11+
<Setter.Value>
12+
<ControlTemplate TargetType="ScrollViewer">
13+
<Border CornerRadius="2"
14+
BorderBrush="{TemplateBinding BorderBrush}"
15+
BorderThickness="{TemplateBinding BorderThickness}">
16+
<Grid Background="{TemplateBinding Background}">
17+
<Grid.RowDefinitions>
18+
<RowDefinition Height="*"/>
19+
<RowDefinition Height="Auto"/>
20+
</Grid.RowDefinitions>
21+
<Grid.ColumnDefinitions>
22+
<ColumnDefinition Width="*"/>
23+
<ColumnDefinition Width="Auto"/>
24+
</Grid.ColumnDefinitions>
25+
26+
<ScrollContentPresenter x:Name="ScrollContentPresenter"
27+
CanContentScroll="{TemplateBinding CanContentScroll}"
28+
Cursor="{TemplateBinding Cursor}"
29+
Margin="{TemplateBinding Padding}"
30+
ContentTemplate="{TemplateBinding ContentTemplate}"/>
31+
32+
<Rectangle Grid.Column="1" Grid.Row="1" Fill="#FFE9EEF4"/>
33+
34+
<ScrollBar x:Name="VerticalScrollBar" Width="18" IsTabStop="False"
35+
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
36+
Grid.Column="1" Grid.Row="0" Orientation="Vertical"
37+
ViewportSize="{TemplateBinding ViewportHeight}"
38+
Maximum="{TemplateBinding ScrollableHeight}"
39+
Minimum="0"
40+
Value="{TemplateBinding VerticalOffset}"
41+
Margin="0,-1,-1,-1"/>
42+
43+
<ScrollBar x:Name="HorizontalScrollBar" Height="18" IsTabStop="False"
44+
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
45+
Grid.Column="0" Grid.Row="1" Orientation="Horizontal"
46+
ViewportSize="{TemplateBinding ViewportWidth}"
47+
Maximum="{TemplateBinding ScrollableWidth}"
48+
Minimum="0"
49+
Value="{TemplateBinding HorizontalOffset}"
50+
Margin="-1,0,-1,-1"/>
51+
52+
</Grid>
53+
</Border>
54+
</ControlTemplate>
55+
</Setter.Value>
56+
</Setter>
57+
</Style>
58+
</Window.Resources>
59+
```

0 commit comments

Comments
 (0)