如何在 DataGrid RowDetailTemplate 中获取控件
我有这个 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
I have this Xaml Code and I want to get the DataGrid "dgRemplacement", I try using Name but it doesn't work also with 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;
}
I have succeeded to get the TabItem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试类似:
FindName
参考Try something like:
FindName
Reference