有没有办法通过 s 确定 aToggleButton
是否已检查/未检查DelegateCommand
?
TIA,迈克
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>