Hello!
We have a XamDatagrid that has set the "LabelClickAction" to "SelectField". Now we want to set the font weight of the label to be bold and maybe the background of the fields to be any color. How to do that?
Thanks, Florian
Florian,
For the headers you can use custom style for the LabelPresenter element and change the default triggers in the template. For changing the background you can just add one setter in your CellValuePrenseter style.
<Style x:Key="CheckboxCvp" TargetType="{x:Type DataPresenter:CellValuePresenter}"> <Setter Property="Background" Value="Red"/> ..</Style>
Let me know if you have any questions with this matter.
Hello Vlad,
thanks, this works for the background color and font weight of the cells. But how about the font weight of fields label?
The other issue I ran into now, is that I use ControlTemplate to show checkboxes. How can I change the background color of those cells?
<Style x:Key="CheckboxCvp" TargetType="{x:Type DataPresenter:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataPresenter:CellValuePresenter}"> <CheckBox VerticalAlignment="Center" HorizontalAlignment="Center" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay}"/> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <DataTrigger Binding="{Binding Path=Field.IsSelected, RelativeSource={RelativeSource Self}}" Value="True"> <Setter Property="FontWeight" Value="Bold"/> </DataTrigger> </Style.Triggers></Style>
Check out this style for the CellValuePresenter:
<Grid.Resources>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="BackgroundFieldSelected" Value="Red"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Field.IsSelected,
RelativeSource={RelativeSource Self}}"
Value="True">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>