【发布时间】:2012-01-17 21:21:01
【问题描述】:
我有一个 WPF 表单,其父级为 stackpanel(名称为 MainStackPanel)。它有各种分组框作为它的孩子。每个 groupbox 有两个复选框(checkbox1 和 checkbox2)。
现在我想在 Mainstack 面板中添加一个检查所有按钮,单击该按钮将自动检查每个组中的所有 checkbox1。
我是 WPF 新手,正在尝试了解如何实现这一目标
<EDIT>
<StackPanel x:Name="MainStackPanel" Orientation="Vertical">
<Grid DataContext="{Binding}">
<Button Content="UnCheck All" Height="23" Name="uncheckall"
Width="75" Margin="434,0,492,0" />
<Button Content="Check All" Height="23" Name="checkall" Width="75"
Margin="175,0,751,0" Click="checkall_Click" />
</Grid>
<GroupBox>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox x:Name="checkbox1"
Style="{StaticResource styleCheckBoxLeftSideText}"
IsChecked="{Binding Path=Disabled,
Converter={StaticResource BooleanConverter},
ConverterParameter='false,true'}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Content="Task Enabled:"
Margin="9,0,0,0"/>
</Grid>
</GroupBox>
</StackPanel>
</EDIT>
【问题讨论】:
-
到目前为止你做了/尝试了什么?向我们展示一些代码会很有帮助。
-
这里是stackpanel代码和groupbox代码。 (组框有一个网格,复选框在网格内)
-
你有模型支持你的 UI 吗?