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
350
How to apply CellValuePresenter style in AssignFieldLayout
posted

Hello,

I have a multilevel hierarchical XamDataGrid. I wan to Indent parent and child in only first column of every child record.

For this, I tried to apply CellValuePresenter style to first column of child record's FieldLayout with Left Margin 20.

It works fine for first child record but for second child level onwards also it applies margin 20 to first field.

Whereas for second child now left margin should be 40 and third level child should have left margin of 60 and so on.

I thought of achieving this by applying cellvaluepresenter to every field layout from code behind by multiplying left margin by nesting depth of current record or by adding 20 to parent record's margin. Is this possible?  

How do I achieve this? or is there any work around. Other solutions are not working as expected for me.

Thanks,

Priya

Parents
  • 34830
    Offline posted

    Hello Priya,

    From your description, I am gathering that you want to indent the child rows further and further with each hierarchical level.

    To do this, I would not recommend doing anything with the CellValuePresenter, but rather the DataRecordPresenter. To do this without having to write any Styles, I would recommend handling the XamDataGrid’s Loaded event and use a for-loop to loop from 0 to MyXamDataGrid.FieldLayouts.Count. In this loop, you can get the FieldLayout and create a Style for DataRecordPresenter that sets the Margin property. Then, set the style on the FieldLayout using MyFieldLayout.Settings.DataRecordPresenterStyle = myStyle.

    Alternatively, consider the method demonstrated here: http://stackoverflow.com/questions/5514093/xamdatagrid-indenting-nested-levels.

    Please note that these methods require you to define your hierarchical levels manually.

    I have attached a sample application demonstrating the Loaded event recommendation.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Developer Support Engineer I
    Infragistics Inc.
    www.infragistics.com/support

    XDGIndentCase.zip
Reply Children