<Style x:Key="cellstyle" TargetType="syncfusion:GridCell"> <Setter Property="FontWeight" Value="{Binding CellFontWeight,Source={StaticResource viewmodel}}"/> <Setter Property="FontFamily" Value="{Binding CellFontFamily,Source={StaticResource viewmodel}}"/> <Setter Property="Background" Value="{Binding CellBackground,Source={StaticResource viewmodel}}"/> <Setter Property="FontSize" Value="{Binding CellFontSize,Source={StaticResource viewmodel}}"/> <syncfusion:SfDataGrid x:Name="grid" AllowEditing="True" AllowFiltering="True" AllowSorting="True" HeaderRowHeight="30" CellStyle="{StaticResource cellstyle}" AutoGenerateColumns="False" ItemsSource="{Binding Stud}" |
<Style x:Key="headerstyle" TargetType="syncfusion:GridHeaderCellControl"> <Setter Property="FontWeight" Value="{Binding HeaderFontWeight,Source={StaticResource viewmodel}}"/> <Setter Property="FontFamily" Value="{Binding HeaderFontFamily,Source={StaticResource viewmodel}}"/> <Setter Property="Background" Value="{Binding HeaderBackground,Source={StaticResource viewmodel}}"/> <Setter Property="FontSize" Value="{Binding HeaderFontSize,Source={StaticResource viewmodel}}"/> <syncfusion:SfDataGrid x:Name="grid" AllowEditing="True" AllowFiltering="True" AllowSorting="True" HeaderRowHeight="30" HeaderStyle="{StaticResource headerstyle}" AutoGenerateColumns="False" ItemsSource="{Binding Stud}" |
<Style TargetType="syncfusion:GridStackedHeaderCellControl"> <Setter Property="FontWeight" Value="{Binding StackedHeaderFontWeight,Source={StaticResource viewmodel}}"/> <Setter Property="FontFamily" Value="{Binding StackedHeaderFontFamily,Source={StaticResource viewmodel}}"/> <Setter Property="Background" Value="{Binding StackedHeaderBackground,Source={StaticResource viewmodel}}"/> <Setter Property="FontSize" Value="{Binding StackedHeaderFontSize,Source={StaticResource viewmodel}}"/> |
<syncfusion:GridTextColumn HeaderText="Roll No" MappingName="Rollno" |
var dataContext = this.DataContext as StudentCollection;
Style gridCellStyle = new Style(typeof(GridCell));
gridCellStyle.Setters.Add(new Setter(GridCell.FontWeightProperty, dataContext.CellFontWeight));
gridCellStyle.Setters.Add(new Setter(GridCell.FontFamilyProperty, dataContext.CellFontFamily));
gridCellStyle.Setters.Add(new Setter(GridCell.BackgroundProperty, dataContext.CellBackground));
gridCellStyle.Setters.Add(new Setter(GridCell.FontSizeProperty, dataContext.CellFontSize));
grid.CellStyle = gridCellStyle;
Style headerCellStyle = new Style(typeof(GridHeaderCellControl));
headerCellStyle.Setters.Add(new Setter(GridHeaderCellControl.FontWeightProperty, dataContext.HeaderFontWeight));
headerCellStyle.Setters.Add(new Setter(GridHeaderCellControl.FontFamilyProperty, dataContext.HeaderFontFamily));
headerCellStyle.Setters.Add(new Setter(GridHeaderCellControl.BackgroundProperty, dataContext.HeaderBackground));
headerCellStyle.Setters.Add(new Setter(GridHeaderCellControl.FontSizeProperty, dataContext.HeaderFontSize));
grid.HeaderStyle = headerCellStyle;
Style stackedHeaderCellStyle = new Style(typeof(GridStackedHeaderCellControl));
stackedHeaderCellStyle.Setters.Add(new Setter(GridStackedHeaderCellControl.FontWeightProperty, dataContext.StackedHeaderFontWeight));
stackedHeaderCellStyle.Setters.Add(new Setter(GridStackedHeaderCellControl.FontFamilyProperty, dataContext.StackedHeaderFontFamily));
stackedHeaderCellStyle.Setters.Add(new Setter(GridStackedHeaderCellControl.BackgroundProperty, dataContext.StackedHeaderBackground));
stackedHeaderCellStyle.Setters.Add(new Setter(GridStackedHeaderCellControl.FontSizeProperty, dataContext.StackedHeaderFontSize));
Resources[typeof(GridStackedHeaderCellControl)]= stackedHeaderCellStyle; |