I have a xamTreeGrid in which there are two field layouts. I want to be able to format the data associated with these fieldlayouts differently.
I am creating the fields, fieldLayouts and adding them to the grid during run time in the code (not declaring the fieldLayouts in xaml).
FieldLayout fl1 = new FieldLayout();
fl1 .Fields.Add(new Field("Field1"));
fl1 .Fields.Add(new Field("Field2"));fl1 .Fields.Add(new Field("Field3"));
FieldLayout fl2 = new FieldLayout();
fl2 .Fields.Add(new Field("Field1"));
fl2 .Fields.Add(new Field("Field2"));fl2 .Fields.Add(new Field("Field3"));
xamTreeGrid.FieldLayouts.add(fl1);
xamTreeGrid.FieldLayouts.add(fl2);
I want to make the data associated with "fl1" as bold and make the text appear in Red. How can I do this in the code?
Hello ,
Thank you for your feedback.
I have modified the sample application from my previous post in order to show you how you can define the style for CellValuePresenter by code.
Please take a look at the attached project and let me know if you require any further assistance regarding this matter.
Thank you for using Infragistics Components!
Zhivko,
I am trying to do the same thing the following way in the code. But I am not able to accomplish it. Little more help here pls.
System.Windows.Style rowStyle = new System.Windows.Style(typeof(CellValuePresenter)); System.Windows.DataTrigger styleTrigger = new System.Windows.DataTrigger { Value = "parent" }; styleTrigger.Binding = new System.Windows.Data.Binding { Path = new System.Windows.PropertyPath("Field.Owner.Key"), RelativeSource = new RelativeSource(RelativeSourceMode.Self) }; styleTrigger.Setters.Add(new System.Windows.Setter(CellValuePresenter.FontWeightProperty, Font.Bold)); rowStyle.Triggers.Add(styleTrigger); m_netlistGrid.Resources.Add("GroupRowFormat", rowStyle);
Thank you for your post.
I have been looking into the functionality you are looking for. I believe in your scenario you can set some key to your f1 FieldLayout, for example string like ‘parent’.
You can create style for CellValuePresenter in the resources of your grid and in it you can access the FieldLayout 's Key property of current cell, by using binding like this Binding="{Binding Path=Field.Owner.Key, RelativeSource={RelativeSource Self}}", so if you put this in a DataTrigger you can easy change the appearance of the cells associated with this layout.
For example:
<Style TargetType="{x:Type igWPF:CellValuePresenter}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Field.Owner.Key, RelativeSource={RelativeSource Self}}" Value="parent">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
I have attached small sample application in order to show you how you can implement this logic and achieve your requirement.
Please let me know if you require any further assistance regarding this matter.