<extensions:CustomDataGridTextColumn HeaderStyle="{StaticResource Nagłówek2tb}" Header="Nagłówek 1" MyProperty ="Nagłówek2"/> Style: <Style TargetType="{x:Type DataGridColumnHeader}" x:Key="Nagłówek2tb"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate > <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding}" TextWrapping="Wrap"/> <TextBlock Grid.Row="1" Text="{Binding MyProperty, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridTextColumn}}"/> </Grid> </DataTemplate> </Setter.Value> </Setter> </Style>
public class CustomDataGridTextColumn : System.Windows.Controls.DataGridTextColumn { public string MyProperty { get { return (string)GetValue(MyPropertyProperty); } set { SetValue(MyPropertyProperty, value); } } public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.Register("MyProperty", typeof(string), typeof(CustomDataGridTextColumn), new UIPropertyMetadata("")); }
TextBlock Grid.Row="1" Text="{Binding MyProperty, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridTextColumn}}"/>
DataGridColumnHeader
BindingProxy
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)