How many searched, found only one option, how can I make a transfer to another line by words. How can this be applied to all text columns?
- Obviously, it is necessary to make the element style and substitute it for the DataGrid column. Probably below you should explain in a more chewed form :) - Deadkenny
- I do not know how to make the style for ElementStyle. It can be defined for DataGridTextColumn, but I don’t understand how to access ElementStyle - Sergеu Isupov
|
1 answer
Something like this.
<Style TargetType="DataGrid" x:Key="MyGrid"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGrid}"> <DataGrid ItemsSource="{TemplateBinding DataGrid.ItemsSource}"> <DataGrid.Columns> <DataGridTextColumn CanUserSort="False" Binding="{Binding Path=direction}" ClipboardContentBinding="{x:Null}" Header="Колонка 1" Width="*" ElementStyle="{StaticResource DataGridCellTextWrap}" /> <DataGridTextColumn CanUserSort="False" Binding="{Binding Path=count}" ClipboardContentBinding="{x:Null}" Header="Колонка 2" Width="90" ElementStyle="{StaticResource DataGridCellTextWrap}" /> </DataGrid.Columns> </DataGrid> </ControlTemplate> </Setter.Value> </Setter> </Style>
Cell style
<Style TargetType="{x:Type TextBlock}" x:Key="DataGridCellTextWrap"> <Setter Property="TextBlock.TextWrapping" Value="Wrap"></Setter> </Style>
|