我正在研究WPF项目,我有以下场景:
每当我单击ToggleSwitch更改其状态时,都会触发Button click事件。
我需要一种方法来阻止这种情况。
<Button x:Name="btn1" Height="40" BorderThickness="0" Width="auto" HorizontalAlignment="Stretch" Margin="0,0,0,0" Style="{DynamicResource SquareButtonStyle}" Click="Button_Click">
<Grid Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Width="auto" Grid.Column="1">Services</TextBlock>
<Controls:ToggleSwitch Grid.Column="3" x:Name="enabledSwitch4"
VerticalAlignment="Center"
Width="Auto"
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}"
OnLabel="" OffLabel=""
IsChecked="True" HorizontalAlignment="Center" />
</Grid>
</Button>