有没有办法确定是否通过DelegateCommands选中/取消选中ToggleButton?
蒂娅,迈克
下面是XAML代码。我正在使用ItemsControl并绑定到一个集合。我基本上是想要一种方法来获得每个按钮被点击时的切换状态。
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Modifiers, Mode=TwoWay}">
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">
<WrapPanel Margin="10" Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
FlowDirection="LeftToRight" IsItemsHost="true">
</WrapPanel>
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ToggleButton FontSize="18" Opacity="0.8"
Command="{Binding DataContext.ModifierToggleCommand,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Views:ModifiersView}}}"
CommandParameter="{Binding}" Height="80" Width="200" Margin="5"
Content="{Binding Path=ModifierName}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>发布于 2009-11-22 11:03:32
更简单的解决方案是将IsChecked属性绑定到ViewModel的属性。这样你只需要检查属性值...
发布于 2009-11-22 10:45:45
您是否可以在XAML中声明性地指定CommandParameter,并使用元素绑定用切换的当前值填充该值?
https://stackoverflow.com/questions/1777632
复制相似问题