DataGridDetailsPresenter가있는 DataGrid (ParentDataGrid)가 있습니다. DataGridDetailsPresenter에는 다른 DataGrid (ChildDataGrid)가 있습니다. ChildDataGrid에서 Row를 선택하면 ParentDataGrid의 주변 DataGridRow도 선택됩니다.DataGridDetailsPresenter를 클릭하여 ParentDataGrid에서 DataGridRow를 선택하지 않으려면 어떻게해야합니까?
ParentDataGrid와 ChildDataGrid가 모두 SelectionChanged 이벤트를 발생시킵니다. ParentDataGrid에서 선택을 취소하려고했습니다. 그러나 ParentDataGrid의 기본 선택이 변경됩니다. 따라서 ParentDataGrid에서 DataGridRow를 선택하지 않는 것이 좋습니다.
DataGridDetailsPresenter를 클릭하여 ParentDataGrid에서 DataGridRow를 선택하지 않으려면 어떻게해야합니까?
이 내 DataTemplate을
<DataTemplate DataType="{x:Type MyViewModel}">
<DataTemplate.Resources>...
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border ...>
<SelectiveScrollingGrid>
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</SelectiveScrollingGrid.RowDefinitions>
<DataGridRowHeader Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" .../>
<DataGridCellsPresenter Grid.Row="0" Grid.Column="1" .../>
<DataGridDetailsPresenter Grid.Row="1" Grid.Column="1" .../>
</SelectiveScrollingGrid>
</Border ...>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataTemplate.Resources>
<Grid ...>
<DataGrid x:Name="ParentDataGrid" ...>
<DataGrid.Columns>...</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Grid ...>
<DataGrid x:Name="ChildDataGrid"...>...</DataGrid>
</Grid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
</Grid>
</DataTemplate>
? 완전한 xaml을 게시하고 가능한 경우 바인딩을위한 샘플 viewmodel을 게시하십시오. – AnjumSKhan
자식 DataGrid는 DataGrid.RowDetailsTemplate에 정의되어 있습니다. 이름을 지금 추가했습니다. 이 자식 DataGrid는 DataGridDetailsPresenter에 표시됩니다. ViewModel은 중요하지 않습니다. DataTemplates를 사용하고 있음을 보여주기 위해 게시했습니다. 두 DataGrid에는 몇 가지 항목이 있습니다. 이 항목들은 독립적 일 수 있습니다. – Christopher
하위 DG는 DataGridDetailsPresenter가있는 RowDetailsTemplate의 DataTemplate에 있습니다. – AnjumSKhan