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
45
Multiple Child rows, controlling the expansion indicator
posted

I have a grid that has two child rows that are generally empty, but will sometimes have data.  With ExpansionIndicatorDisplayMode=CheckOnDisplay, it always shows the expander on the parent row.  When I click the expander, I see the field names for the child rows stacked on top of eachother.  Neither of them have data, so there is not an expansion indicator on them.  How do I make the parent row aware that both of the child rows are empty, so it should also hide its expander?

I've tried setting a DataRecordPresenterStyle with the following, but the expansion indicator shows up on every row still:

<igDP:FieldLayoutSettings.DataRecordPresenterStyle>
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Style.Setters>
<Setter Property="ExpansionIndicatorVisibility" Value="{Binding DataItem.ExpanderVisibility, Mode=OneWay}" />
</Style.Setters>
</Style>
</igDP:FieldLayoutSettings.DataRecordPresenterStyle>

Parents
No Data
Reply
  • 34510
    Suggested Answer
    Offline posted

    Hi Josh,

    The ExpansionIndicatorVisibility property on DataRecordPresenter is locally set (probably in source code?) so your binding won't override that.  The expansion indicator is basically bound to the DataRecordPresenter's DataContext which is a DataRecord.  Inside this DataRecord there is an ExpansionIndicatorVisibility property.  If you set this to Hidden then it should hide the indicator.  The issue is figuring out where to do this.

    At initial load you can handle the InitializeRecord event and then cast e.Record to a DataRecord.  From there you can get the underlying DataItem and check to see if it has children.  If no children exist then set ExpansionIndicatorVisibility on the DataRecord to Hidden.  The only issue I see with this approach is if you will later add items to this child rows.  The indicator for that record won't automatically update so you'll have to iterate the XamDataGrid.Records collection and find that parent DataRecord to reverse the expansion indicator visibility.  If, however, your data is static then you won't need to worry about that.

Children
No Data