Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
335
Specify field formats in filedlayout
posted

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?

Parents
No Data
Reply
  • 16495
    Offline posted

    Hello ,

     

    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.

    FieldLayoutsStyling.zip
Children