我有一个分层数据模型:
public class AssetClassLevelViewModel
{
public string AssetClassName {get; set;}
public ObservableCollection<AssetClassLevelViewModel> ChildAssetClasses {get; set;}
public ObservableCollection<ProductHoldingsWithAllocationViewModel> ProductHoldings {get; set;}
}
图中显示的列标题反映了ProductHoldingsWithAllocationViewModel属性。
我需要在网格顶部移动列标题,并且不希望它们在每个分组级别重复。
有解决方案吗?在xaml中,我将HeaderPlacement
属性设置为OnTopOnly
由于
Hasanain
答案 0 :(得分:2)
我相信您可以使用以下样式来确保标题行仅位于顶部:
<Style TargetType="{x:Type Ig:XamDataGrid}" BasedOn="{StaticResource {x:Type Ig:XamDataGrid}}">
<Setter Property="FieldLayoutSettings">
<Setter.Value>
<igDP:FieldLayoutSettings HeaderPlacement="OnTopOnly" HeaderPlacementInGroupBy="OnTopOnly"/>
</Setter.Value>
</Setter>
</Style>
我相信“OnTopOnly”确保标题行仅显示在网格的最顶部,而不是显示在每个组标题中。
答案 1 :(得分:0)
Infragistics建议我隐藏所有子表头的以下解决方法:
为您的资源添加DataRecordPresenter
的样式:
<local:TestConverter2 x:Key="testconv2"/>
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="Height" Value="{Binding Converter={StaticResource testconv2}}"/>
</Style>
并将以下转换器添加到您的项目中:
public class TestConverter2 : IValueConverter
{
private int count = 0;
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
DataRecord dr = value as DataRecord;
if (dr == null)
{
return double.NaN;
}
if (dr is HeaderRecord)
{
if (this.count < 1)
{
this.count++;
return double.NaN;
}
else
{
return 0;
}
}
else
{
return double.NaN;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value;
}
}
答案 2 :(得分:0)
答案可能有点迟,但在XAML中的XamDataGrid中,您只需要将FilterUIType-Property设置为LabelIcons,并且在XamDataGrid分组时ColumnHeaders将位于顶部。就像这里一样:
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings FilterUIType="LabelIcons"/>
</igDP:XamDataGrid.FieldLayoutSettings>