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 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.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics
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,
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.
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
The previous solution would not really work as dynamic resources are not suitable for elements which are not part of the visual tree, and FieldSettings is not.
I have attached another solution which will resolve the border issues.
If you have any question, please let me know.
XDGApplyThemeAtRuntime_MOD.zip
thanks
There actually still seems to be some issues with the borders for the Office2013 theme, even though the style is picking up the rest of the properties. I will investigate this further and update you accordingly.
Hi,
When applying a theme, you apply a style to all elements of this control. By assigning a style as per my previous post, we assign the default style with some modifications.
In order to modify the style set by the theme, you will have to base the new style on the existing one.
I have attached a sample where I do the following:
I have set a XamComboEditor which sets different themes of the grid. After a theme has been applied, I get the current style of the LabelPresenter and the CellValuePresenter and create new styles based on them.
In the XAML I have the styles which are dynamic resources and I update those resources accordingly when a theme is set, so it will apply to the current style of the elements.
Please check the sample and let me know if you have any further questions.
Sincerely,Tihomir ToneAssociate Software DeveloperInfragistics
XDGApplyThemeAtRuntime.zip
I allow the user to select a theme frmo the IG themes - IG, royal Dark, Royal Light, Office 2010 Blue and Ofice 2013. Office 2010 Blue does have grid lines for my bold cells, but Ofice 2013, which I sent in the
screen shot has these blanked out