Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145129 | Jun 7,2019 05:32 PM UTC | Jun 17,2019 05:00 PM UTC | WPF | 5 |
![]() |
Tags: SfDataGrid |
internal static class BindableColumns
{
public static Columns GetColumns(DependencyObject obj)
{
return (Columns)obj.GetValue(ColumnsProperty);
}
public static void SetColumns(DependencyObject obj, Columns value)
{
obj.SetValue(ColumnsProperty, value);
}
// Using a DependencyProperty as the backing store for Columns. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ColumnsProperty =
DependencyProperty.RegisterAttached("Columns", typeof(Columns), typeof(BindableColumns), new PropertyMetadata(null, OnColumnsPropertyChanged));
public static void OnColumnsPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
var dataGrid = obj as SfDataGrid;
if(dataGrid != null)
dataGrid.Columns = args.NewValue as Columns;
}
} |
<ControlTemplate>
<Grid>
<sf:SfDataGrid x:Name="grid"
AllowFiltering="True"
AllowGrouping="True"
ColumnSizer="Star"
AutoGenerateColumns="False"
ItemsSource="{Binding GridItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
local:BindableColumns.Columns="{Binding GridColumns, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
EnableDataVirtualization="True"
NavigationMode="Row"
ShowBusyIndicator="True"
ShowGroupDropArea="True">
</sf:SfDataGrid>
</Grid>
</ControlTemplate> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.