I have a XamDataGrid which is being populated on a button click.
我有一个XamDataGrid,它正在点击按钮时填充。
<Expander Header="{Binding Path=Tag, ElementName=EditGridExpanderBar}" Tag="Edit Grid" Visibility="Hidden" Height="Auto" Name="EditGridExpanderBar" FontWeight="Bold" Background="#6688A4" Margin="0,0,5,3" Padding="3,0,0,0" Foreground="White">
<igDP:XamDataGrid Name="EditGrid">
</igDP:XamDataGrid>
</Expander>
Here is the code for populating the XamDataGrid.
这是填充XamDataGrid的代码。
private void EditAllocations_Click (object sender, RoutedEventArgs e)
{
ObservableCollection<LobAllocation> ds = _controller.PlanitariumModel.Entity.LobAllocations;
if (editGridClickCheck((Button)sender, ds.Count))
{
EditGrid.DataSource = ds;
}
}
Here, the entity has some MetaData fields which are being displayed along with the actual columns in the Grid. I want to hide these fields manually.
这里,实体有一些MetaData字段,它们与Grid中的实际列一起显示。我想手动隐藏这些字段。
Any pointers on how to do this?
有关如何做到这一点的任何指示?
1 个解决方案
#1
1
You cannot hide specific fields. What you can do is switching off the auto column generation which is based on the public properties of the class which the datagrid is binding to. Also, you need to specify which properties should be displayed in the datagrid.
您无法隐藏特定字段。你可以做的是关闭自动列生成,它基于datagrid绑定的类的公共属性。此外,您需要指定应在datagrid中显示哪些属性。
Try like this:
试试这样:
<igDP:XamDataGrid Name="EditGrid">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:Field Name="EntityProperty-1" Label="Property1" />
<igDP:Field Name="EntityProperty-2" Label="Property2" />
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False"/>
</igDP:XamDataGrid.FieldLayoutSettings>
</igDP:XamDataGrid>
In the <igDP:FieldLayout>
block you need to specify the columns of the Datagrid you want to present. With the following block you can disable the auto generation of the columns .
在
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False"/>
</igDP:XamDataGrid.FieldLayoutSettings>
#1
1
You cannot hide specific fields. What you can do is switching off the auto column generation which is based on the public properties of the class which the datagrid is binding to. Also, you need to specify which properties should be displayed in the datagrid.
您无法隐藏特定字段。你可以做的是关闭自动列生成,它基于datagrid绑定的类的公共属性。此外,您需要指定应在datagrid中显示哪些属性。
Try like this:
试试这样:
<igDP:XamDataGrid Name="EditGrid">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:Field Name="EntityProperty-1" Label="Property1" />
<igDP:Field Name="EntityProperty-2" Label="Property2" />
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False"/>
</igDP:XamDataGrid.FieldLayoutSettings>
</igDP:XamDataGrid>
In the <igDP:FieldLayout>
block you need to specify the columns of the Datagrid you want to present. With the following block you can disable the auto generation of the columns .
在
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False"/>
</igDP:XamDataGrid.FieldLayoutSettings>