Skip to content

Commit 1e6644b

Browse files
author
shobika.palani
committed
How to customize style of the ScrollViewer in wpf datagrid
1 parent 76494c6 commit 1e6644b

23 files changed

+1348
-0
lines changed

WPF/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
5+
</startup>
6+
</configuration>

WPF/App.ico

4.19 KB
Binary file not shown.

WPF/App.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application x:Class="SfDataGridDemo.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
7+
</Application.Resources>
8+
</Application>

WPF/App.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace SfDataGridDemo
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}

WPF/MainWindow.xaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<Window
2+
x:Class="SfDataGridDemo.MainWindow"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:Syncfusion="http://schemas.syncfusion.com/wpf"
6+
xmlns:local="clr-namespace:SfDataGridDemo"
7+
Title="SfDataGrid Demo"
8+
WindowStartupLocation="CenterScreen">
9+
<Window.Resources>
10+
<Style TargetType="ScrollViewer">
11+
<Setter Property="Template">
12+
<Setter.Value>
13+
<ControlTemplate TargetType="ScrollViewer">
14+
<Border CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
15+
<Grid Background="{TemplateBinding Background}">
16+
<Grid.RowDefinitions>
17+
<RowDefinition Height="*"/>
18+
<RowDefinition Height="Auto"/>
19+
</Grid.RowDefinitions>
20+
<Grid.ColumnDefinitions>
21+
<ColumnDefinition Width="*"/>
22+
<ColumnDefinition Width="Auto"/>
23+
</Grid.ColumnDefinitions>
24+
25+
<ScrollContentPresenter x:Name="ScrollContentPresenter"
26+
CanContentScroll="{TemplateBinding CanContentScroll}"
27+
Cursor="{TemplateBinding Cursor}"
28+
Margin="{TemplateBinding Padding}"
29+
ContentTemplate="{TemplateBinding ContentTemplate}"/>
30+
31+
<Rectangle Grid.Column="1" Grid.Row="1" Fill="#FFE9EEF4"/>
32+
33+
<ScrollBar x:Name="VerticalScrollBar" Width="18"
34+
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"
44+
IsTabStop="False"
45+
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
46+
Grid.Column="0" Grid.Row="1" Orientation="Horizontal"
47+
ViewportSize="{TemplateBinding ViewportWidth}"
48+
Maximum="{TemplateBinding ScrollableWidth}"
49+
Minimum="0"
50+
Value="{TemplateBinding HorizontalOffset}"
51+
Margin="-1,0,-1,-1"/>
52+
53+
</Grid>
54+
</Border>
55+
</ControlTemplate>
56+
</Setter.Value>
57+
</Setter>
58+
</Style>
59+
</Window.Resources>
60+
61+
<Window.DataContext>
62+
<local:ViewModel/>
63+
</Window.DataContext>
64+
65+
<Grid>
66+
<Syncfusion:SfDataGrid
67+
x:Name="sfdatagrid"
68+
ItemsSource="{Binding EmployeeDetails}" >
69+
</Syncfusion:SfDataGrid>
70+
</Grid>
71+
</Window>

WPF/MainWindow.xaml.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Windows;
5+
using Syncfusion.UI.Xaml.Grid;
6+
using Syncfusion.UI.Xaml.Grid.Helpers;
7+
using Syncfusion.UI.Xaml.ScrollAxis;
8+
9+
namespace SfDataGridDemo {
10+
/// <summary>
11+
/// Interaction logic for MainWindow.xaml
12+
/// </summary>
13+
public partial class MainWindow : Window
14+
{
15+
public MainWindow()
16+
{
17+
InitializeComponent();
18+
}
19+
}
20+
}

WPF/Model/Model.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace SfDataGridDemo
9+
{
10+
public class Model : INotifyPropertyChanged
11+
{
12+
private int employeeID;
13+
private string employeeName;
14+
private string city;
15+
private int employeeAge;
16+
private double employeeSalary;
17+
public int EmployeeID
18+
{
19+
get { return employeeID; }
20+
set
21+
{
22+
employeeID = value;
23+
OnPropertyChanged("EmployeeID");
24+
}
25+
}
26+
public string EmployeeName
27+
{
28+
get { return employeeName; }
29+
set
30+
{
31+
employeeName = value;
32+
OnPropertyChanged("EmployeeName");
33+
}
34+
}
35+
public int EmployeeAge
36+
{
37+
get { return employeeAge; }
38+
set
39+
{
40+
employeeAge = value;
41+
OnPropertyChanged("EmployeeAge");
42+
}
43+
}
44+
public double EmployeeSalary
45+
{
46+
get { return employeeSalary; }
47+
set
48+
{
49+
employeeSalary = value;
50+
OnPropertyChanged("EmployeeSalary");
51+
}
52+
}
53+
54+
public string City
55+
{
56+
get { return city; }
57+
set
58+
{
59+
city = value;
60+
OnPropertyChanged("City");
61+
}
62+
}
63+
64+
public event PropertyChangedEventHandler PropertyChanged;
65+
private void OnPropertyChanged(string propertyName)
66+
{
67+
if (PropertyChanged != null)
68+
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
69+
}
70+
}
71+
}

WPF/Properties/AssemblyInfo.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyTitle("SfDataGridDemo")]
11+
[assembly: AssemblyDescription("")]
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyCompany("")]
14+
[assembly: AssemblyProduct("SfDataGridDemo")]
15+
[assembly: AssemblyCopyright("Copyright © 2015")]
16+
[assembly: AssemblyTrademark("")]
17+
[assembly: AssemblyCulture("")]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[assembly: ComVisible(false)]
23+
24+
//In order to begin building localizable applications, set
25+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
26+
//inside a <PropertyGroup>. For example, if you are using US english
27+
//in your source files, set the <UICulture> to en-US. Then uncomment
28+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
29+
//the line below to match the UICulture setting in the project file.
30+
31+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32+
33+
34+
[assembly: ThemeInfo(
35+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36+
//(used if a resource is not found in the page,
37+
// or application resource dictionaries)
38+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39+
//(used if a resource is not found in the page,
40+
// app, or any theme specific resource dictionaries)
41+
)]
42+
43+
44+
// Version information for an assembly consists of the following four values:
45+
//
46+
// Major Version
47+
// Minor Version
48+
// Build Number
49+
// Revision
50+
//
51+
// You can specify all the values or you can default the Build and Revision Numbers
52+
// by using the '*' as shown below:
53+
// [assembly: AssemblyVersion("1.0.*")]
54+
[assembly: AssemblyVersion("1.0.0.0")]
55+
[assembly: AssemblyFileVersion("1.0.0.0")]

WPF/Properties/Resources.Designer.cs

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)