我有这个Xaml代码,我想获取DataGrid“dgRemplacement”,我尝试使用Name,但它也不适用于Uid。
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Grid Background="#FF4088C0" Name="DetailGrid">
<TabControl>
<TabItem Header="Detaille">
</TabItem>
<TabItem Header="Intervention">
</TabItem>
<TabItem Header="Detaille Intervention">
</TabItem>
<TabItem Header="Remplacement">
<Grid Background="#FFE5E5E5">
<DataGrid Name="dgRemplacement" x:Uid="DataGrid1">
<DataGrid.Columns>
<DataGridTextColumn Header="Article(Serie)" Binding="{Binding Designation}"/>
<DataGridTextColumn Header="Qte" Binding="{Binding Qte}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
</TabControl>
</Grid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
private void dgBILigne_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e)
{
TabControl tc = (e.DetailsElement as Grid).Children[0] as TabControl;
TabItem ti = tc.Items[3] as TabItem;
}
我成功获得了TabItem
答案 0 :(得分:0)
尝试类似:
var dataGrid = (e.DetailsElement as FrameworkElement).FindName("dgRemplacement") as DataGrid;