Answer the question
In order to leave comments, you need to log in
How to deactivate all toggle buttons except one on click?
There are 8 toggle buttons. When one of the buttons is clicked, all the others become isEnable = False
How to do this?
It is advisable to do this in code and not in xaml, since these buttons will still call other methods
<!--Toggle Button-->
<Style x:Key="ToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="#535353"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinHeight" Value="30"/>
<Setter Property="Grid.Column" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}"
BorderThickness="0">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ToggleButton x:Name="CategoryToggle1"
Grid.Row="1"
Style="{StaticResource ToggleButton}"
Checked="ShowOptions"
Unchecked="HideOptions" />
Answer the question
In order to leave comments, you need to log in
Define this style
<Window.Resources>
<Style TargetType="RadioButton" BasedOn="{StaticResource {x:Type ToggleButton}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ToggleButton IsChecked="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<RadioButton Grid.Column="0" Width="50" Height="50" />
<RadioButton Grid.Column="1" Width="50" Height="50" />
<RadioButton Grid.Column="2" Width="50" Height="50" />
</Grid>
<RadioButton GroupName="Group1"/>
<RadioButton GroupName="Group1"/>
<RadioButton GroupName="Group1"/>
<RadioButton GroupName="Group2"/>
<RadioButton GroupName="Group2"/>
<RadioButton GroupName="Group2"/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question