Reputation: 11
I'm working on WPF Application. I have 3 Toggle Button in my application. I'm using Image in toggle button. I'm using this toggle buttons for choose screen mode(1 screen or 3 screen or 4 screen).
<GroupBox >
<StackPanel Orientation="Horizontal">
<ToggleButton Height="50" Padding="10 5 10 5" Margin="5">
<Image Source="content/1screen.png"/>
</ToggleButton>
<ToggleButton Height="50" Padding="10 5 10 5" Margin="5">
<Image Source="content/3screen.png"/>
</ToggleButton>
<ToggleButton Height="50" Padding="10 5 10 5" Margin="5">
<Image Source="content/4screen.png"/>
</ToggleButton>
</StackPanel>
</GroupBox>
So I have to choose just one of them. For example: if i choose 3 screen toggle button, than i choose 4 screen toggle button, the 3 screen toggle button have to be unchecked. Is there a anyone to help me?
Upvotes: 1
Views: 843
Reputation: 7885
Easiest solution is to just use RadioButtons but style them like ToggleButtons like so:
<RadioButton Style="{StaticResource {x:Type ToggleButton}}" />
This creates a RadioButton but applies the styling from ToggleButton, so you can do whatever you can with RadioButtons but it will look like a ToggleButton. To then be able to only choose one, yo can use the GroupName
property as explained here
Upvotes: 1