Hello,
I have a datagrid with a nested layout. This is all working fine until I have created an inherited version of BindableBase.
When adding a public property of type List (normal bool and string is fine) I get an additional nested layer.
The issue disappears if I change "CustomBoolList" to internal/private/protected.
Why do I get an additional nested layer even though I have already added "Browsable=false".
public class ExtendedBindableBase : BindableBase { [Browsable(false)] public List<bool> CustomBoolList { get; set; } }
public class DataLevel1 : ExtendedBindableBase { public string L1_col1 { get; set; } public string L1_col2 { get; set; } public string L1_col3 { get; set; } public string L1_col4 { get; set; } public ObservableCollection<DataLevel2> L2_items { get; set; } public DataLevel1( ) { } } public class DataLevel2 : BindableBase { public string L2_col1 { get; set; } public string L2_col2 { get; set; } public DataLevel2( ) { } }
<igDP:XamDataGrid x:Name="_dataGrid" DataSource="{Binding Path=L1}"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:XamDataGrid}"> <Setter Property="Background" Value="DarkGray"/> </Style> <Style x:Key="drcaStyle" TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="CornerRadius" Value="0"/> <Setter Property="Background" Value="White"/> <Setter Property="BackgroundAlternate" Value="WhiteSmoke"/> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings HighlightAlternateRecords="True" DataRecordChildIndent="50" DataRecordCellAreaStyle="{StaticResource drcaStyle}" > </igDP:FieldLayoutSettings> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout Key="FL_DataL1"> <igDP:FieldLayout.Fields> <igDP:Field Name="L1_col1" Label="L1 - col1" LabelTextWrapping="Wrap" Width="70" IsReadOnly="True" AllowEdit="False" FixedLocation="FixedToNearEdge" VerticalContentAlignment="Top" /> <igDP:Field Name="L1_col2" Label="L1 - col2" IsReadOnly="True" AllowEdit="False" FixedLocation="FixedToNearEdge" VerticalContentAlignment="Top" /> <igDP:TextField Name="L1_col3" Label="L1 - col3" IsReadOnly="True" AllowEdit="False" FixedLocation="FixedToNearEdge" VerticalContentAlignment="Top" IsScrollTipField="True" /> <igDP:TextField Name="L1_col4" Label="L1 - col4" LabelTextWrapping="Wrap" Width="200" TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Stretch" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> <igDP:FieldLayout Key="FL_DataL2" ParentFieldLayoutKey="FL_DataL1"> <igDP:FieldLayout.Fields> <igDP:Field Name="L2_col1" Label="L2 - col1" IsReadOnly="True" FixedLocation="FixedToNearEdge" VerticalContentAlignment="Top" /> <igDP:Field Name="L2_col2" Label="L2 - col2" IsReadOnly="True" FixedLocation="FixedToNearEdge" VerticalContentAlignment="Top" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Unfortunately, I cannot upload images.
Thank you, I am glad I was able to help. Let me know if you have any additional questions.
Thank you, this solves the issue.
It is just difficult to understand why entending a class ended in this weird behaviour.
This was just a simple example. In case you have more nested levels (like me) and you do not want to expand sub levels automatically then using this changed code:
private bool _isXamDataGrid_RecordExpanding = false; private void XamDataGrid_RecordExpanding( object sender, Infragistics.Windows.DataPresenter.Events.RecordExpandingEventArgs e ) { if ( _isXamDataGrid_RecordExpanding ) return; _isXamDataGrid_RecordExpanding = true; foreach ( var item in e.Record.ViewableChildRecords ) { item.IsExpanded = true; } _isXamDataGrid_RecordExpanding = false; }
Hello and thank you for clarifying. I apologize, this wasn't as trivial as I would have hoped. Turns out to do this you have to hide the ExpandableFieldRecordPresenter, set ExpandableFieldRecordHeaderDisplayMode="NeverDisplayHeader" and hook the grid's RecordExpanding event and manually expand the ViewableChildRecords. This was previously answered here:
https://es.infragistics.com/community/forums/f/ultimate-ui-for-wpf/120095/implementing-hierarchical-data-binding-in-wpf-xamdatagrid
I attached a modified sample to achieve this. Let me know if you have any questions. 7485.WpfApp16.zip
Here is your sample with adjustments to show the issue.
WpfApp16_kvzt.zip
Current behaviour (public List<bool> CustomBoolList):
Expected (protected List<bool> CustomBoolList):
Please review and modify my sample attached to isolate the issue. I wasn't able to reproduce the behavior with the dummy data attached.
WpfApp16.zip