user2877627
user2877627

Reputation:

How can i change borderbrush of checked Radiobuttons in XAML?

I have set of radio buttons when either of them are checked as true i want to change their border brush to "Aqua" while getting back to checked as false border brush to be black i wanna do that in XAML neither in vb.net nor in C#...

    <StackPanel Margin="10">
        <RadioButton GroupName="OS" Content="Win. XP" IsChecked="True" BorderBrush="Aqua" BorderThickness="50"/>
        <RadioButton GroupName="OS" Content="Win. 7"/>
        <RadioButton GroupName="OS" Content="Win. 8"/>
        <StackPanel Margin="10"/>
        <RadioButton GroupName="Office" Content="Office Xp"/>
        <RadioButton GroupName="Office" Content="Microsoft Office 2007"/>
        <RadioButton GroupName="Office" Content="Microsoft Office 2003"/>
    </StackPanel>

Thanx In Advance..

Upvotes: 0

Views: 1968

Answers (1)

Sriram Sakthivel
Sriram Sakthivel

Reputation: 73482

You can use Triggers for this purpose

<StackPanel Margin="10">
    <StackPanel.Resources>
        <Style TargetType="RadioButton">
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="BorderBrush" Value="Aqua"></Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </StackPanel.Resources>
    <RadioButton GroupName="OS" Content="Win. XP" IsChecked="True"/>
    <RadioButton GroupName="OS" Content="Win. 7"/>
    <RadioButton GroupName="OS" Content="Win. 8"/>
    <StackPanel Margin="10"/>
    <RadioButton GroupName="Office" Content="Office Xp"/>
    <RadioButton GroupName="Office" Content="Microsoft Office 2007"/>
    <RadioButton GroupName="Office" Content="Microsoft Office 2003"/>
</StackPanel>

Upvotes: 2

Related Questions