我有一个数据网格绑定到时间表行的集合。
在每一行中,我在最后一列中包含了一个自定义用户控件,该控件由3个单选按钮组成。这些指示每行应为“帐单”,“保留”还是“写出”。 在数据网格的标题模板中,我包含了一个稍有不同的控件,该控件允许用户选择“全部清除”,“全部保留”,“全部取消”
[有问题的按钮... 1
如何获取标题按钮以影响下面的行按钮的更改。
这是我第一次使用WPF,并且试图确保我坚持正确的WPF理想和结构。我试图将Click事件分配给标题按钮,该事件将创建行按钮的数组,并将其IsSelected属性设置为true。
但是我确定我应该使用类似“附加属性”的东西。
这些是包装在UserControl中的单选按钮
LineButtons.xaml
<StackPanel Orientation="Horizontal" IsHitTestVisible="True">
<RadioButton Style="{StaticResource GridLineButton}" x:Name="BillButton" Template="{DynamicResource ToggleButtonLeft}">Bill</RadioButton>
<RadioButton Style="{StaticResource GridLineButton}" x:Name="HoldButton" Template="{DynamicResource ToggleButtonMid}">Hold</RadioButton>
<RadioButton Style="{StaticResource GridLineButton}" x:Name="WOButton" Template="{DynamicResource ToggleButtonRight}">Write Off</RadioButton>
</StackPanel>
HeaderButtons.xaml
<StackPanel Orientation="Horizontal" IsHitTestVisible="True">
<RadioButton Style="{StaticResource GridLineButton}" >Bill All</RadioButton>
<RadioButton Style="{StaticResource GridLineButton}" >Hold All</RadioButton>
<RadioButton Style="{StaticResource GridLineButton}" >Write Off All</RadioButton>
</StackPanel>
Datagrid.xaml
<DataGridTemplateColumn>
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<local:HeaderButtons Padding="0"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<local:LineButtons Padding="4"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
我希望所有行按钮都可以从标题按钮设置。 例如。如果用户单击“全部开票”(在标题中),我希望将所有“开票”按钮都设置为“选定”。
任何帮助将不胜感激。