Xceed DataGrid:删除详细信息行上方的间距
Xceed DataGrid: Remove spacing above detail rows
如何删除 Xceed 在详细信息行之前自动放置的间距?通常这里有一个标题,但我将其设置为空,因为我不想要它。标红的间距最烦人
我发现替换这一行:
<xcdg:DetailConfiguration RelationName="Settings" Title="">
这一行:
<xcdg:DetailConfiguration RelationName="Settings" Title="" UseDefaultHeadersFooters="False">
将删除标记为红色的 space。但是它也删除了我的 header:
|名称 |说明 |编辑值 |编辑值 |
这是我的代码:
<UserControl.Resources>
<!--#region DataTemplateSelector-->
<local:SettingsDataTemplateSelector x:Key="SettingsDataTemplateSelector" />
<DataTemplate x:Key="TextboxDataTemplate">
<xcdg:MaskedTextBox IsTabStop="True" Mask="{Binding EditMask}" Text="{Binding EditValue, IsAsync=False, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnExceptions=True}"/>
</DataTemplate>
<DataTemplate x:Key="ComboDataTemplate">
<ComboBox IsTabStop="True" ItemsSource="{Binding Path=SelectionValues}"
SelectedValuePath="Value"
SelectedValue="{Binding Path=SelectionValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ValueText">
</ComboBox>
</DataTemplate>
<DataTemplate x:Key="SliderDataTemplate">
<Slider IsTabStop="True" Value="{Binding EditSliderValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Minimum="{Binding MinRangeValue}"
Maximum="{Binding MaxRangeValue}"
VerticalAlignment="Bottom"
IsSnapToTickEnabled="True"
TickFrequency="1"
Margin="0,0,0,0"/>
</DataTemplate>
<!--#endregion-->
<xcdg:DataGridCollectionViewSource x:Key="Features"
Source ="{Binding Path=Demo.Features}"
AutoFilterMode="And"
AutoCreateDetailDescriptions="False"
AutoCreateItemProperties="False">
<xcdg:DataGridCollectionViewSource.DetailDescriptions>
<xcdg:PropertyDetailDescription RelationName="Settings" AutoCreateDetailDescriptions="False" AutoCreateItemProperties="False"/>
</xcdg:DataGridCollectionViewSource.DetailDescriptions>
</xcdg:DataGridCollectionViewSource>
</UserControl.Resources>
<Grid>
<!--#region Xceed DataGrid-->
<xcdg:DataGridControl x:Name="datagrid"
ItemsSource="{Binding Source={StaticResource Features}}"
KeyUp="DatagridKeyUp"
AllowDetailToggle="True"
Margin="10"
NavigationBehavior="RowOrCell"
CellEditorDisplayConditions="RowIsBeingEdited,
MouseOverCell, MouseOverRow, RowIsCurrent, CellIsCurrent"
EditTriggers="BeginEditCommand, ClickOnCurrentCell,
SingleClick, CellIsCurrent, ActivationGesture, RowIsCurrent"
ItemScrollingBehavior="Immediate"
AutoCreateColumns="False">
<xcdg:DataGridControl.Resources>
<Style TargetType="xcdg:TableViewScrollViewer">
<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
</Style>
</xcdg:DataGridControl.Resources>
<xcdg:DataGridControl.View>
<xcdg:TableflowView UseDefaultHeadersFooters="False" ColumnStretchMode="Last">
<xcdg:TableflowView.FixedHeaders>
<DataTemplate>
<xcdg:ColumnManagerRow />
</DataTemplate>
</xcdg:TableflowView.FixedHeaders>
</xcdg:TableflowView>
</xcdg:DataGridControl.View>
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="FeatureID" Title="FeatureID" ReadOnly="True" />
<xcdg:Column FieldName="Name" Title="Feature name" ReadOnly="True" />
<xcdg:Column FieldName="Description" Title="Description" ReadOnly="True" />
<xcdg:Column FieldName=" "/>
</xcdg:DataGridControl.Columns>
<xcdg:DataGridControl.DetailConfigurations>
<xcdg:DetailConfiguration RelationName="Settings" Title="">
<xcdg:DetailConfiguration.Columns>
<xcdg:Column FieldName="Name" Title="Name" ReadOnly="True"/>
<xcdg:Column FieldName="Description" Title="Description" ReadOnly="True"/>
<xcdg:Column FieldName="EditValues" Title="Edit Values" ReadOnly="True"/>
<xcdg:Column FieldName="EditValueVar" Title="Edit Value" Width="150" ReadOnly="False"
CellContentTemplateSelector="{StaticResource SettingsDataTemplateSelector}"
DisplayMemberBinding="{Binding}" />
<xcdg:Column FieldName=" "/>
</xcdg:DetailConfiguration.Columns>
</xcdg:DetailConfiguration>
</xcdg:DataGridControl.DetailConfigurations>
</xcdg:DataGridControl>
<!--#endregion-->
</Grid>
编辑:我想出了如何摆脱蓝色间距,但仍然无法弄清楚如何摆脱红色。
代码:
<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
<Setter Property="MaxWidth" Value="0" />
</Style>
您可能认为可以添加 <Setter Property="MaxHeight" Value="0" />
,但这没有任何作用。
蓝色间距由 HierarchicalGroupLevelIndicatorPane 设置,这意味着您只需将宽度设置为 0 即可摆脱它:
<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
<Setter Property="MaxWidth" Value="0" />
</Style>
红色间距有点难。最后,我在 DetailConfiguration 上将 UseDefaultHeadersFooters 设置为 false,这会删除 space,但也会删除 ColumnManagerRow。然后我在 DetailConfiguration.Headers 中再次创建 ColumnManagerRow。
代码如下所示:
<xcdg:DataGridControl.DetailConfigurations>
<xcdg:DetailConfiguration RelationName="Settings" UseDefaultHeadersFooters="False">
<xcdg:DetailConfiguration.Headers>
<DataTemplate>
<xcdg:ColumnManagerRow />
</DataTemplate>
</xcdg:DetailConfiguration.Headers>
<xcdg:DetailConfiguration.Columns>
<xcdg:Column FieldName="Name" Title="Name" ReadOnly="True" />
<xcdg:Column FieldName="Description" Title="Description" ReadOnly="True" />
<xcdg:Column FieldName="EditValues" Title="Edit Values" ReadOnly="True" />
<xcdg:Column FieldName="EditValueVar" Title="Edit Value" Width="150" ReadOnly="False"
CellContentTemplateSelector="{StaticResource SettingsDataTemplateSelector}"
DisplayMemberBinding="{Binding}" />
<xcdg:UnboundColumn FieldName=" " />
</xcdg:DetailConfiguration.Columns>
</xcdg:DetailConfiguration>
</xcdg:DataGridControl.DetailConfigurations>
如何删除 Xceed 在详细信息行之前自动放置的间距?通常这里有一个标题,但我将其设置为空,因为我不想要它。标红的间距最烦人
我发现替换这一行:
<xcdg:DetailConfiguration RelationName="Settings" Title="">
这一行:
<xcdg:DetailConfiguration RelationName="Settings" Title="" UseDefaultHeadersFooters="False">
将删除标记为红色的 space。但是它也删除了我的 header:
|名称 |说明 |编辑值 |编辑值 |
这是我的代码:
<UserControl.Resources>
<!--#region DataTemplateSelector-->
<local:SettingsDataTemplateSelector x:Key="SettingsDataTemplateSelector" />
<DataTemplate x:Key="TextboxDataTemplate">
<xcdg:MaskedTextBox IsTabStop="True" Mask="{Binding EditMask}" Text="{Binding EditValue, IsAsync=False, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnExceptions=True}"/>
</DataTemplate>
<DataTemplate x:Key="ComboDataTemplate">
<ComboBox IsTabStop="True" ItemsSource="{Binding Path=SelectionValues}"
SelectedValuePath="Value"
SelectedValue="{Binding Path=SelectionValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ValueText">
</ComboBox>
</DataTemplate>
<DataTemplate x:Key="SliderDataTemplate">
<Slider IsTabStop="True" Value="{Binding EditSliderValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Minimum="{Binding MinRangeValue}"
Maximum="{Binding MaxRangeValue}"
VerticalAlignment="Bottom"
IsSnapToTickEnabled="True"
TickFrequency="1"
Margin="0,0,0,0"/>
</DataTemplate>
<!--#endregion-->
<xcdg:DataGridCollectionViewSource x:Key="Features"
Source ="{Binding Path=Demo.Features}"
AutoFilterMode="And"
AutoCreateDetailDescriptions="False"
AutoCreateItemProperties="False">
<xcdg:DataGridCollectionViewSource.DetailDescriptions>
<xcdg:PropertyDetailDescription RelationName="Settings" AutoCreateDetailDescriptions="False" AutoCreateItemProperties="False"/>
</xcdg:DataGridCollectionViewSource.DetailDescriptions>
</xcdg:DataGridCollectionViewSource>
</UserControl.Resources>
<Grid>
<!--#region Xceed DataGrid-->
<xcdg:DataGridControl x:Name="datagrid"
ItemsSource="{Binding Source={StaticResource Features}}"
KeyUp="DatagridKeyUp"
AllowDetailToggle="True"
Margin="10"
NavigationBehavior="RowOrCell"
CellEditorDisplayConditions="RowIsBeingEdited,
MouseOverCell, MouseOverRow, RowIsCurrent, CellIsCurrent"
EditTriggers="BeginEditCommand, ClickOnCurrentCell,
SingleClick, CellIsCurrent, ActivationGesture, RowIsCurrent"
ItemScrollingBehavior="Immediate"
AutoCreateColumns="False">
<xcdg:DataGridControl.Resources>
<Style TargetType="xcdg:TableViewScrollViewer">
<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
</Style>
</xcdg:DataGridControl.Resources>
<xcdg:DataGridControl.View>
<xcdg:TableflowView UseDefaultHeadersFooters="False" ColumnStretchMode="Last">
<xcdg:TableflowView.FixedHeaders>
<DataTemplate>
<xcdg:ColumnManagerRow />
</DataTemplate>
</xcdg:TableflowView.FixedHeaders>
</xcdg:TableflowView>
</xcdg:DataGridControl.View>
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="FeatureID" Title="FeatureID" ReadOnly="True" />
<xcdg:Column FieldName="Name" Title="Feature name" ReadOnly="True" />
<xcdg:Column FieldName="Description" Title="Description" ReadOnly="True" />
<xcdg:Column FieldName=" "/>
</xcdg:DataGridControl.Columns>
<xcdg:DataGridControl.DetailConfigurations>
<xcdg:DetailConfiguration RelationName="Settings" Title="">
<xcdg:DetailConfiguration.Columns>
<xcdg:Column FieldName="Name" Title="Name" ReadOnly="True"/>
<xcdg:Column FieldName="Description" Title="Description" ReadOnly="True"/>
<xcdg:Column FieldName="EditValues" Title="Edit Values" ReadOnly="True"/>
<xcdg:Column FieldName="EditValueVar" Title="Edit Value" Width="150" ReadOnly="False"
CellContentTemplateSelector="{StaticResource SettingsDataTemplateSelector}"
DisplayMemberBinding="{Binding}" />
<xcdg:Column FieldName=" "/>
</xcdg:DetailConfiguration.Columns>
</xcdg:DetailConfiguration>
</xcdg:DataGridControl.DetailConfigurations>
</xcdg:DataGridControl>
<!--#endregion-->
</Grid>
编辑:我想出了如何摆脱蓝色间距,但仍然无法弄清楚如何摆脱红色。
代码:
<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
<Setter Property="MaxWidth" Value="0" />
</Style>
您可能认为可以添加 <Setter Property="MaxHeight" Value="0" />
,但这没有任何作用。
蓝色间距由 HierarchicalGroupLevelIndicatorPane 设置,这意味着您只需将宽度设置为 0 即可摆脱它:
<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
<Setter Property="MaxWidth" Value="0" />
</Style>
红色间距有点难。最后,我在 DetailConfiguration 上将 UseDefaultHeadersFooters 设置为 false,这会删除 space,但也会删除 ColumnManagerRow。然后我在 DetailConfiguration.Headers 中再次创建 ColumnManagerRow。
代码如下所示:
<xcdg:DataGridControl.DetailConfigurations>
<xcdg:DetailConfiguration RelationName="Settings" UseDefaultHeadersFooters="False">
<xcdg:DetailConfiguration.Headers>
<DataTemplate>
<xcdg:ColumnManagerRow />
</DataTemplate>
</xcdg:DetailConfiguration.Headers>
<xcdg:DetailConfiguration.Columns>
<xcdg:Column FieldName="Name" Title="Name" ReadOnly="True" />
<xcdg:Column FieldName="Description" Title="Description" ReadOnly="True" />
<xcdg:Column FieldName="EditValues" Title="Edit Values" ReadOnly="True" />
<xcdg:Column FieldName="EditValueVar" Title="Edit Value" Width="150" ReadOnly="False"
CellContentTemplateSelector="{StaticResource SettingsDataTemplateSelector}"
DisplayMemberBinding="{Binding}" />
<xcdg:UnboundColumn FieldName=" " />
</xcdg:DetailConfiguration.Columns>
</xcdg:DetailConfiguration>
</xcdg:DataGridControl.DetailConfigurations>