Trigger for button enable - c#

I have two buttons. How I can enable second button after clicking on first button using only xaml.
<Window.Resources>
<Style x:Key="NewButtonStyle" TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SecondButton, Path=IsEnabled,Mode=TwoWay}" Value="True">
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Button x:Name="FirstButton" Content="Button" HorizontalAlignment="Left" Margin="10,22,0,0" VerticalAlignment="Top" Width="75" Style="{StaticResource NewButtonStyle}"/>
<Button x:Name="SecondButton" Content="Button" HorizontalAlignment="Left" Margin="105,22,0,0" VerticalAlignment="Top" Width="75" IsEnabled="False"/>
</Grid>

You have to add two references in order to use Interaction.Triggers and ChangePropertyAction (System.Windows.Interactivity and Microsoft.Expression.Interactions)
<Button x:Name="FirstButton" Content="Button" HorizontalAlignment="Left" Margin="10,22,0,0" VerticalAlignment="Top" Width="75">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:ChangePropertyAction TargetName="SecondButton" PropertyName="IsEnabled" Value="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button x:Name="SecondButton" Content="Button" HorizontalAlignment="Left" Margin="105,22,0,0" VerticalAlignment="Top" Width="75" IsEnabled="False"/>

Related

WPF Move control based on other control

I've got the following <canvas>:
<Canvas>
<ToggleButton Height="30" Width="125" Name="DisplayCanvas"
Background="Transparent"
BorderBrush="Transparent" Canvas.ZIndex="1" Cursor="Hand"
ClickMode="Press" Canvas.Top="11">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"/>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
<Image Source="../Images/Button/customise.png" Height="30" Width="30" Canvas.Top="11"/>
<Label Content="Customize" VerticalAlignment="Center" Canvas.Left="31" Canvas.Top="14" Foreground="White"/>
<Path Data="M0,10 L5,0 L10,10" Stroke="White"
Height="8"
StrokeThickness="2" HorizontalAlignment="Center" Canvas.Left="101.733"
Canvas.Top="22" Stretch="Fill" Width="15">
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=DisplayCanvas, Path=IsChecked}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=DisplayCanvas, Path=IsChecked}" Value="False">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
<Path Data="M0,10 L5,0 L10,10" Stroke="White" StrokeThickness="2" HorizontalAlignment="Center" Canvas.Left="102" Height="8" Canvas.Top="23.733" Stretch="Fill" Width="15" RenderTransformOrigin="0.5,0.5">
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=DisplayCanvas, Path=IsChecked}" Value="True">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=DisplayCanvas, Path=IsChecked}" Value="False">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<EventTrigger RoutedEvent="Path.Loaded">
<BeginStoryboard>
<Storyboard >
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" BeginTime="0:0:0" Duration="0:0:1" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</Path.Style>
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="181.918"/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
<Button Content="" Height="30" Width="65"
Background="Transparent" BorderBrush="Transparent" Canvas.ZIndex="1" Cursor="Hand" Canvas.Top="128">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction
Command="{Binding Help}"
CommandParameter="{Binding RelativeSource= {RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext}">
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Image Source="../Images/Button/help.png" Height="30" Width="30" Canvas.Top="128"></Image>
<Label Content="Help" VerticalAlignment="Center" Canvas.Left="32" Canvas.Top="131" Foreground="White"></Label>
<Canvas Visibility="{Binding IsChecked, ElementName=DisplayCanvas, Converter={StaticResource InverseBooleanToVisibilityConverter}}" Name="CustomisationCanvas">
<Button Content="" Height="30" Width="71" Canvas.Top="57"
Background="Transparent" BorderBrush="Transparent" Canvas.ZIndex="1" Cursor="Hand" Canvas.Left="44">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction
Command="{Binding CustomiseAvatar}"
CommandParameter="{Binding RelativeSource= {RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext}">
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Image Source="../Images/Button/customise.png" Height="30" Width="30" Canvas.Top="56" Canvas.Left="44"></Image>
<Label Content="Avatar" VerticalAlignment="Center" Canvas.Left="74" Canvas.Top="60" Foreground="White"></Label>
<Button Content="" Height="30" Width="71" Canvas.Top="97"
Background="Transparent" BorderBrush="Transparent" Canvas.ZIndex="1" Cursor="Hand" Canvas.Left="44">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction
Command="{Binding CustomiseSkin}"
CommandParameter="{Binding RelativeSource= {RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext}">
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Image Source="../Images/Button/customise.png" Height="30" Width="30" Canvas.Top="97" Canvas.Left="44"/>
<Label Content="Skin" VerticalAlignment="Center" Canvas.Left="74" Canvas.Top="100" Foreground="White"/>
</Canvas>
</Canvas>
What I need to do is when the canvas is displayed, I need to move the HelpButton down, when it is hidden, move the HelpButton back up.Is this possible? Almost like a ContextMenu.
You could try to use a Button style that binds to the Visibility property of the Canvas and sets the Canvas.Top attached property of the Button:
<Button Content="" Height="30" Width="65" Background="Transparent" BorderBrush="Transparent" Canvas.ZIndex="1" Cursor="Hand">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Canvas.Top" Value="128" />
<Style.Triggers>
<DataTrigger Binding="{Binding Visibility, ElementName=CustomisationCanvas}" Value="Collapsed">
<Setter Property="Canvas.Top" Value="100" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction
Command="{Binding Help}"
CommandParameter="{Binding RelativeSource= {RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext}">
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
i think your massively over complicating your layout
Here is a simpler example that uses a Toggle to show and hide content
<StackPanel>
<HeaderedContentControl >
<HeaderedContentControl.Header>
<ToggleButton x:Name="toggleShow">Show/Hide</ToggleButton>
</HeaderedContentControl.Header>
<StackPanel Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=toggleShow}">
<Label>test</Label>
<Label>test</Label>
<Label>test</Label>
</StackPanel>
</HeaderedContentControl>
<Label>help</Label>
</StackPanel>

Disable Label click over Button but enable the mouseover

I have a label over Button control now i want hover effect on label but i want to disable click event on label.
So here is the summary of problem.
1.Label is placed over Button.
2.I want click event of button not for Label.
3.Setting IsHitTestVisible="False" of label disbales the click as well as mouse over effect.
4.So,Now i want to disable click in label but not the mouse over effect.
Here is the code
<Button Content="OK" Height="25" IsDefault="true" HorizontalAlignment="Left" Name="okButton"
VerticalAlignment="Top" Width="56" Click="Ok_button" Visibility="Visible" OpacityMask="#00000000"
Margin="-2,-3,0,0" IsTabStop="False" />
<Label Content="OK" Height="24" HorizontalAlignment="Left" Name="OKLabel" VerticalAlignment="Top"
Width="141" FontSize="10" FontFamily="Arial" FontWeight="Bold" BorderBrush="Black"
BorderThickness="0" OpacityMask="Black" Foreground="White" Focusable="False" Style="{StaticResource oklabel}" IsEnabled="True" IsHitTestVisible="False">
</Label>
<Window.Resources>
<Style TargetType="{x:Type Label}" x:Key="oklabel">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="10" ShadowDepth="0" Opacity="1" Color="White"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>

The resource "XX" could not be resolved

I'm getting the following error when I run my program:
Warning The resource "bellRingersStyle" could not be resolved.
This comes up for the last two lines that are {StaticResource bellRingersStyle}.
<Window x:Class="BellRingers.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Middleshire Bell Ringers Association – Members" Height="350" Width="525">
<Window.Resources>
<Style x:Key="bellRingerStyle" TargetType="Control">
<Setter Property="Button.Background" Value="Gray"/>
<Setter Property="Button.Foreground" Value="Gray"/>
<Setter Property="Button.FontFamily" Value="Comic Sans MS"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Blue"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Button Style="{StaticResource bellRingerStyle}" Panel.ZIndex="1" Content="Button" Height="23" HorizontalAlignment="Left" Margin="400,131,0,0" Name="button1" VerticalAlignment="Top" Width="75" >
</Button>
<Button Style="{StaticResource bellRingersStyle}" Panel.ZIndex="1" Content="Button" Height="23" Margin="0,0,0,0" Name="button2" Width="75" />
<Image Panel.ZIndex="0" Margin="0,0,0,0" Name="image1" >
<Image.Source>
<BitmapImage UriSource="bell.gif" />
</Image.Source>
</Image>
<TextBox Style="{StaticResource bellRingersStyle}" Height="23" HorizontalAlignment="Left" Margin="206,271,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
</Grid>
</Window>
You have a typo. You defined it as bellRingerStyle but reference bellRingersStyle.

Binding WPF User Control

I am developing an application with MVVm in wpf.
Here I have to place a user control to another user control.
Main user control will have have the UI elements to save the information. in addtion , I need to place a user control where I have a list view. I need to populate the data to the list view.
XAML is as follows
<UserControl x:Class="SMTF.TestCaseView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SMTF" mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
d:DesignHeight="550" d:DesignWidth="508">
<UserControl.Resources>
<Style x:Key="SMToggle" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}" >
<Border CornerRadius="3" Background="{TemplateBinding Background}">
<ContentPresenter Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content" Value="Show View"/>
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFF3F3F3" Offset="1"/>
<GradientStop Color="#FFF3F3F3" Offset="0.307"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Content" Value="Add New"/>
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFF3F3F3" Offset="1"/>
<GradientStop Color="#FFF3F3F3" Offset="0.307"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Height="550" Width="508">
<Button Content="Save" Command="{Binding SaveData}" Height="23" HorizontalAlignment="Left" Margin="299,507,0,0" Name="btnSave" VerticalAlignment="Top" Width="75" />
<Button Content="Reset" Command="{Binding ClearData}" Height="23" HorizontalAlignment="Right" Margin="0,507,47,0" Name="btnReset" VerticalAlignment="Top" Width="75" />
<Label Content="Category" Height="28" HorizontalAlignment="Left" Margin="13,27,0,0" Name="lblCategory" VerticalAlignment="Top" />
<ComboBox DisplayMemberPath="Category_Desc" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="343" Margin="118,27,0,0" Name="cboCategory"
ItemsSource="{Binding Path=Category}"
SelectedValue="{Binding Path=Category_Id}"
SelectedValuePath="Category_Id"
Text="{Binding Category_Desc}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding CategorySelected}"
CommandParameter="{Binding SelectedValue, ElementName=cboCategory}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="Sub Category" Height="28" HorizontalAlignment="Left" Margin="13,65,0,0" Name="lblSubCategory" VerticalAlignment="Top" />
<ComboBox DisplayMemberPath="Sub_Category_Desc" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="343" Margin="118,65,0,0" Name="cboSubCategory"
ItemsSource="{Binding Path=SubCategory}"
SelectedValue="{Binding Path=Sub_Category_Id}"
SelectedValuePath="Sub_Category_Id"
Text="{Binding Sub_Category_Desc}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SubCategorySelected}"
CommandParameter="{Binding SelectedValue, ElementName=cboSubCategory}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="Scenario" Height="28" HorizontalAlignment="Left" Margin="13,101,0,0" Name="lblScenario" VerticalAlignment="Top" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="118,101,0,0" Name="cboScenario" VerticalAlignment="Top" Width="343"
ItemsSource="{Binding Path=Scenario}"
DisplayMemberPath="Scenario_Desc"
SelectedValuePath="Scenario_Id"
SelectedValue="{Binding Path=Scenario_Id}"
Text="{Binding Scenario_Desc}"
/>
<TextBox Height="118" HorizontalAlignment="Left" Margin="118,139,0,0" Name="txtCulture" Text="{Binding Test_Desc}" VerticalAlignment="Top" Width="340" />
<Label Content="Test Description" Height="28" HorizontalAlignment="Left" Margin="13,137,0,0" Name="lblCulture" VerticalAlignment="Top" />
<Label Content="Applicable to" Height="28" HorizontalAlignment="Left" Margin="13,280,0,0" Name="lblVersion" VerticalAlignment="Top" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="118,285,0,0" Name="Version" VerticalAlignment="Top" Width="343"
ItemsSource="{Binding Path=Version}"
DisplayMemberPath="Version_Desc"
SelectedValuePath="Version_Id"
SelectedValue="{Binding Path=Version_Id}"
Text="{Binding Version_Desc}"
/>
<CheckBox Content="Activate" Height="16" HorizontalAlignment="Left" IsChecked="{Binding Active}" Margin="402,263,0,0" Name="chkActive" VerticalAlignment="Top" />
<local:TestScriptListView HorizontalAlignment="Left" Margin="118,349,0,0" x:Name="scriptList" VerticalAlignment="Top" Height="148" Width="343" DataContext="{Binding Path=Script}" />
<Label Content="Script" Height="28" HorizontalAlignment="Left" Margin="13,318,0,0" Name="lblScript" VerticalAlignment="Top" />
<TextBlock HorizontalAlignment="Left" Margin="118,118,0,0" Height="32">
<ToggleButton x:Name="VisibilityToggle" Focusable="False" Command ="{Binding ShowNew}" Style="{StaticResource SMToggle}" >
<Image Source="/Image/Add.png" Width="16" Height="16" />
</ToggleButton>
</TextBlock>
</Grid>
</UserControl>
How to solve this?
thanks
NS
Add reference your Listview's Usercontrol in entry usercontrol and set Datacontext .
like-
< StackPanel>
< views:ExceptionStrip DataContext="{Binding ExceptionViewModel}"/>
< /StackPanel>

How to set the IsChecked property of a RadioButton from the Contents of a ComboBox declaratively?

I have a comboBox which has the following items: a1, a2, a3, a4 and I have two RadioButtons r1 and r2.
This is what I want to accomplish:
if the user selects item a2 from the combobox the IsChecked property of r1 should be set to true. If the user selects either item a3 or a4 from the combobox the IsChecked propertyr of r2 should be set to true. I would like to accomplish this declaratively; i.e. without using a Converter.
Here is my Code and thanks in advance:
<Window x:Class="BMSystem.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="myRadioActivator1">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Content, ElementName=comboBox1}" Value="R2">
<Setter Property="RadioButton.IsChecked" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="myRadioActivator2">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Content, ElementName=comboBox1}" Value="R3">
<Setter Property="RadioButton.IsChecked" Value="True"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Content, ElementName=comboBox1}" Value="R4">
<Setter Property="RadioButton.IsChecked" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" SelectionChanged="comboBox1_SelectionChanged">
<ComboBoxItem>R1</ComboBoxItem>
<ComboBoxItem>R2</ComboBoxItem>
<ComboBoxItem>R3</ComboBoxItem>
<ComboBoxItem>R4</ComboBoxItem>
</ComboBox>
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,43,0,0" Name="r1" VerticalAlignment="Top" Width="120" Style="{StaticResource myRadioActivator1}">
</RadioButton>
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,69,0,0" Name="r2" VerticalAlignment="Top" Width="120" Style="{StaticResource myRadioActivator2}">
</RadioButton>
</Grid>
</Window>
I think your goal of doing this without a converter is good, but your goal of doing it entirely declaratively is questionable. I'd add an IsChecked property to the view model of the ComboBox's items and bind to it. Putting the decision-making process that underlies the setting of that property into the view seems, to me, to be muddying up the separation of concerns.
Man... those are some weird requirements!
Here is one solution:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<XmlDataProvider x:Key="CBOptions">
<x:XData>
<Data xmlns="">
<Option Name="R1" />
<Option Name="R2" IsR1Checked="True" />
<Option Name="R3" IsR2Checked="True" />
<Option Name="R4" IsR2Checked="True" />
</Data>
</x:XData>
</XmlDataProvider>
<DataTemplate x:Key="CBItemTemplate">
<TextBlock Text="{Binding XPath=#Name}" />
</DataTemplate>
</Page.Resources>
<Grid DataContext="{Binding ElementName=comboBox1, Path=SelectedItem}">
<ComboBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="comboBox1"
VerticalAlignment="Top" Width="120" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource CBOptions}, XPath=Data/Option}"
ItemTemplate="{StaticResource CBItemTemplate}" />
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,43,0,0"
Name="r1" VerticalAlignment="Top" Width="120" GroupName="R1"
IsChecked="{Binding XPath=#IsR1Checked}" />
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,69,0,0"
Name="r2" VerticalAlignment="Top" Width="120" GroupName="R2"
IsChecked="{Binding XPath=#IsR2Checked}" />
</Grid>
</Page>
You could do it by moving everything into a DataTemplate and using Triggers there. I would probably consider Robert's suggestion that this be fixed in a ViewModel or some other bound object because it sounds more like it might be more business logic than just UI. That said:
<ContentControl Content="{Binding}">
<ContentControl.ContentTemplate>
<DataTemplate>
<Grid>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" SelectionChanged="comboBox1_SelectionChanged"
SelectedValuePath="Content">
<ComboBoxItem>R1</ComboBoxItem>
<ComboBoxItem>R2</ComboBoxItem>
<ComboBoxItem>R3</ComboBoxItem>
<ComboBoxItem>R4</ComboBoxItem>
</ComboBox>
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,43,0,0" Name="r1" VerticalAlignment="Top" Width="120" >
</RadioButton>
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,69,0,0" Name="r2" VerticalAlignment="Top" Width="120" >
</RadioButton>
</Grid>
<DataTemplate.Triggers>
<Trigger SourceName="comboBox1" Property="SelectedValue" Value="R2">
<Setter TargetName="r1" Property="RadioButton.IsChecked" Value="True"/>
</Trigger>
<Trigger SourceName="comboBox1" Property="SelectedValue" Value="R3">
<Setter TargetName="r2" Property="RadioButton.IsChecked" Value="True"/>
</Trigger>
<Trigger SourceName="comboBox1" Property="SelectedValue" Value="R4">
<Setter TargetName="r2" Property="RadioButton.IsChecked" Value="True"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>

Categories