public class SfDataGridExt : SfDataGrid
{
public SfDataGridExt()
: base()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SfDataGridExt), new FrameworkPropertyMetadata(typeof(SfDataGridExt)));
}
} |
<local:SfDataGridExt x:Name="grid"
AllowGrouping="True"
AutoGenerateColumns="False"
ItemsSource="{Binding EmployeeDetails}"
ShowGroupDropArea="True">
<local:SfDataGridExt.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Syncfusion.SfGrid.WPF;component/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</local:SfDataGridExt.Resources>
</local:SfDataGridExt>
|
public class SfDataGridExt : SfDataGrid
{
protected ToolBarAdv toolBarRow;
protected SfTextBoxExt textSearch;
public SfDataGridExt()
: base()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SfDataGridExt), new FrameworkPropertyMetadata(typeof(SfDataGridExt)));
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
toolBarRow = GetTemplateChild("ToolBarRow") as ToolBarAdv;
textSearch = GetTemplateChild("TxtSearch") as SfTextBoxExt;
//vb code
//toolBarRow = TryCast(GetTemplateChild("ToolBarRow"), ToolBarAdv)
//textSearch = TryCast(GetTemplateChild("TxtSearch"), SfTextBoxExt)
}
} |
<Style TargetType="{x:Type local:SfDataGridExt}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="#FFC8E3E3" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="HeaderRowHeight" Value="30" />
<Setter Property="RowSelectionBrush" Value="#FFdff3f4" />
<Setter Property="GroupRowSelectionBrush" Value="#FFdff3f4" />
<Setter Property="CurrentCellBorderThickness" Value="2" />
<Setter Property="CurrentCellBorderBrush" Value="#FF26A0DA" />
<Setter Property="SelectionForegroundBrush" Value="#FF2A2A2A" />
</Style> |
<local:SfDataGridExt.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Syncfusion.SfGrid.WPF;component/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="syncfusion:GridGroupSummaryCell">
<Setter Property="HorizontalContentAlignment" Value="Right" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontStyle" Value="Italic" />
</Style>
<Style TargetType="syncfusion:GridTableSummaryCell">
<Setter Property="HorizontalContentAlignment" Value="Right" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style TargetType="syncfusion:UnBoundRowControl">
<Setter Property="BorderThickness" Value="2" />
</Style>
</ResourceDictionary>
</local:SfDataGridExt.Resources> |
<UserControl.Resources>
<Style x:Key="groupSummaryStyle" TargetType="syncfusion:GridGroupSummaryCell">
<Setter Property="HorizontalContentAlignment" Value="Right" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontStyle" Value="Italic" />
</Style>
</UserControl.Resources>
<local:SfDataGridExt x:Name="grid"
AllowGrouping="True"
GroupSummaryCellStyle="{StaticResource groupSummaryStyle}"
ItemsSource="{Binding EmployeeDetails}"
ShowGroupDropArea="True"> |
<local:UnboundCellStyleConverter x:Key="unboundCellStyleConverter" />
<Style TargetType="syncfusion:GridUnBoundRowCell">
<Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource unboundCellStyleConverter}}" />
</Style> |
public class UnboundCellStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var index = (value as GridUnBoundRowCell).ColumnBase.RowIndex;
if (index % 2 == 0)
return Colors.Bisque.ToString();
else
return Colors.LightSkyBlue.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
} |
private void Grid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var visualcontainer = this.grid.GetVisualContainer();
var rowcolumindex = visualcontainer.PointToCellRowColumnIndex(e.GetPosition(visualcontainer));
if (rowcolumindex.IsEmpty)
{
if(this.grid.ShowGroupDropArea == true && e.GetPosition(visualcontainer).Y < 0)
{
MessageBox.Show("Clicked in grop drop area");
}
}
var datarow = grid.RowGenerator.Items.FirstOrDefault(dr => dr.RowIndex == rowcolumindex.RowIndex);
//You can the row type -> Header, Record, Caption and etc rows types using below variable
if(datarow.RowType == RowType.HeaderRow)
{
MessageBox.Show("You are Clicked in HeaderRow");
}
if(datarow.RowType==RowType.UnBoundRow)
{
MessageBox.Show("You are Clicked in UnBoundRow");
}
if (datarow.RowType == RowType.DefaultRow)
{
MessageBox.Show(" You are Clicked in DefaultRow");
}
} |
<syncfusion:GridNumericColumn MappingName="EmployeeSalary" TextAlignment="Right" NumberDecimalDigits="3" NumberDecimalSeparator="," NumberGroupSeparator="" NumberGroupSizes="2" AllowNullValue="True"/>
<syncfusion:GridDateTimeColumn MappingName="EmployeeDate" Pattern="CustomPattern" CustomPattern="dd/MM/yy" AllowNullValue="True" /> |