我有一个带有 2 个标签页的标签项。我想在每个标签页中放置 4 个复选框,所有复选框都具有相同的属性。如何轻松完成?
问问题
118 次
1 回答
0
将所有复选框绑定到同一个属性(从您的 ViewModel 中,您确实有一个,对吗?)。然后它们都将显示相同的信息。
绑定代码不多..您可以尝试类似...
<TabControl>
<TabItem Header="Tab1">
<StackPanel>
<CheckBox Content="One" Checked="{Binding Path=MyProperty}"/>
<CheckBox Content="Two" Checked="{Binding Path=MyProperty}"/>
</StackPanel>
</TabItem>
<TabItem Header="Tab2">
<StackPanel>
<CheckBox Content="Three" Checked="{Binding Path=MyProperty}"/>
<CheckBox Content="Four" Checked="{Binding Path=MyProperty}"/>
</StackPanel>
</TabItem>
</TabControl>
..whereMyProperty
是一个本地属性,表示您要显示的状态。
于 2009-07-16T07:29:24.110 回答