0

是否可以通过将鼠标拖到多个 ToggleButtons 上(按住鼠标左键)来切换它们的状态?

4

2 回答 2

1

框中没有任何支持此功能的内容,但您应该能够订阅MouseMove并在按下按钮时切换状态。

于 2013-02-08T16:45:40.697 回答
0
<ToggleButton Content="ToggleButton" MouseEnter="ToggleButtonMouseEnter" Width="80" HorizontalAlignment="Left"/>

private void ToggleButtonMouseEnter(object sender, MouseEventArgs e)
{
     System.Windows.Controls.Primitives.ToggleButton tb = (System.Windows.Controls.Primitives.ToggleButton)sender;
     if(e.LeftButton == MouseButtonState.Pressed) tb.IsChecked = !tb.IsChecked;
}
于 2013-02-08T18:22:16.230 回答