I have a xamDatagrid which allows the user to key into 3 our of 12 columns. I would like to highlight the columns they can key into by changing the background/foreground of the column heading.
I would also like whatever they key to be shown in bold.
How do I specify this in XAML ?
Hello,
I suppose the grid you have is having a theme or has been restyled, so when you have assigned the CellValuePresenter style to the field, it overrides the one applied on grid level.
If you have another style for CVP, what you can do is use basedOn attribute:
<Style TargetType="{x:Type igDP:LabelPresenter}" x:Key="customLabel" basedOn="{StaticResource otherCVPStyle}">
If that's not the case, would it be possible to send me a small sample to see where the grid lines are coming from, as the default style of XamDataGrid does not come with borders between cells in the same field.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics
Thanks. This great. Just one think more if that's OK - how do I keep the grid lines round the cells in the columns I apply the bold style to ? As you can see below, the grid lines round each cell have disappeared on teh columns I applied this to
If setting these options will not be dynamic with binding, and you will be hardcoding it to specific fields, I can suggest creating a style fitting your requirements for LabelPresenter and CellValuePresenter, and assigning them to the fields LabelPresenterStyle and CellValuePresenterStyle properties.
Here is a simple example:
<Style TargetType="{x:Type igDP:LabelPresenter}" x:Key="customLabel"> <Setter Property="Foreground" Value="Yellow"/> <Setter Property="Background" Value="Red"/> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="customCVP"> <Setter Property="FontWeight" Value="Bold"/> </Style>
And then in the FieldSettings:
<igDP:Field Name="Name"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource customLabel}" CellValuePresenterStyle="{StaticResource customCVP}"/> </igDP:Field.Settings> </igDP:Field>
Please let me know if you have more questions about this.
Here is a snipped of the XAML defining some of my columns
<ig:Field Label="List Price" IsTabStop="False" AlternateBinding="{Binding Price}" HorizontalContentAlignment="Right"> <ig:Field.Settings> <ig:FieldSettings AllowHiding="Default" AllowEdit="False" Width="100" /> </ig:Field.Settings> </ig:Field>
<ig:Field Label="Discount" IsTabStop="False" AlternateBinding="{Binding Discountrate, Mode=TwoWay}" HorizontalContentAlignment="Right"> <ig:Field.Settings> <ig:FieldSettings AllowHiding="Default" AllowEdit="False" Width="80" /> </ig:Field.Settings> </ig:Field>
<ig:Field Label="Cases" AlternateBinding="{Binding Casesordered, Mode=TwoWay}" Format="##,###" HorizontalContentAlignment="Right" > <ig:Field.Settings> <ig:FieldSettings AllowHiding="Default" AllowEdit="True" Width="80" /> </ig:Field.Settings> </ig:Field>
<ig:Field Label="Units" AlternateBinding="{Binding Unitsordered, Mode=TwoWay}" Format="##,###" HorizontalContentAlignment="Right"> <ig:Field.Settings> <ig:FieldSettings AllowHiding="Default" AllowEdit="True" Width="80" /> </ig:Field.Settings> </ig:Field>
I am allowing them to edit data in 2 of the columns - cases and units. I want t o be able to change the column heading for these columns to make them stand out, and show the contents of the these columns in bold or a slightly bigger font size to make them stand out
Hello Gordon,
Thank you for reaching out.
You can style the LabelPresenter with a DataTrigger on the key or the property identifying the field can be entered by the user. Here is an example how to bind to the Tag property of a Field:
<Style TargetType="{x:Type igDP:LabelPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Field.Tag, RelativeSource={RelativeSource Self}}" Value="Key"> <Setter Property="Foreground" Value="Yellow"/> <Setter Property="Background" Value="Red"/> </DataTrigger> </Style.Triggers> </Style>
However, I don't understand what you mean by key(there is no key property of the Field class, but if you give me some more details, I will be happy to help you.