我是世界粮食计划署的新成员,我尝试每行使用Telerik
网格和子项。
这是我的xaml:
<telerikGrid:RadGridView x:Name="rgvProductsMatricolari" ItemsSource="{Binding CustomerProducts}" ... >
<telerikGrid:RadGridView.ChildTableDefinitions>
...
</telerikGrid:RadGridView.ChildTableDefinitions>
<telerikGrid:RadGridView.Columns>
<telerikGrid:GridViewDataColumn x:Name="SelProductsMatricolari" Header ="" Width="Auto" TextAlignment="Center">
<telerikGrid:GridViewDataColumn.CellTemplate>
<DataTemplate>
<CheckBox x:Name="chkProductsMatricolari" Style="{StaticResource chkStandard}" IsChecked="{Binding IsSelected, Mode=TwoWay}" HorizontalAlignment="Center" />
</DataTemplate>
</telerikGrid:GridViewDataColumn.CellTemplate>
</telerikGrid:GridViewDataColumn>
<!-- other columns -->
</telerikGrid:RadGridView.Columns>
<telerikGrid:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<Grid IsEnabled="{Binding SelectedItem, ElementName=rgvProductsMatricolari}" Visibility="{Binding SelectedItem, ElementName=rgvProductsMatricolari, Converter={StaticResource BooleanToVisibility}}">
<!-- the grid -->
</Grid>
</DataTemplate>
</telerikGrid:RadGridView.HierarchyChildTemplate>
</telerikGrid:RadGridView>
如您所见,如果选择了父行的Grid
(checkbox
模型),我想要禁用和隐藏子IsSelected
。
我{Binding SelectedItem, ElementName=rgvProductsMatricolari}
遇到了一些问题,因为点击checkbox
请不要选择该行。
如何绑定子网格&#34; IsEnabled
&#34;属于&#34; IsSelected
&#34;父数据的属性?
答案 0 :(得分:1)
试试这个:
<Grid IsEnabled="{Binding DataContext.IsSelected, RelativeSource={RelativeSource AncestorType=telerik:GridViewRow}}" ... >