WPF has such powerful binding capabilities that you should not have to handle control events as you do above. Here's a quickly put together example that shows you what you can do (please keep in mind that I have not done too much error checking, case-insensitive compare etc. - the code is just an example for you):
<ComboBox ItemsSource="{Binding Strings}" SelectedItem="{Binding Combo1String}"
Height="23" HorizontalAlignment="Left" Margin="36,35,0,0"
Name="comboBox1" VerticalAlignment="Top" Width="120" />
<ComboBox ItemsSource="{Binding Strings}" SelectedItem="{Binding Combo2String}"
Height="23" HorizontalAlignment="Left" Margin="202,35,0,0"
Name="comboBox2" VerticalAlignment="Top" Width="120" />
<TextBox Text="{Binding Status}"
Height="23" HorizontalAlignment="Left" Margin="42,90,0,0"
Name="textBox1" VerticalAlignment="Top" Width="257" />
public MainWindow()
{
InitializeComponent();
this.Strings = new[] { "yes", "no" };
this.PropertyChanged += MainWindow_PropertyChanged;
}
void MainWindow_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName.StartsWith("Combo"))
{
if (this.Combo1String == "yes" & this.Combo1String == this.Combo2String)
{
this.Status = "Cleared";
}
else
{
this.Status = "Not cleared";
}
}
}
public string[] Strings { get; set; }
private string combo1String;
public string Combo1String
{
get { return combo1String; }
set
{
if (combo1String != value)
{
combo1String = value;
this.FirePropertyChanged("Combo1String");
}
}
}
private string combo2String;
public string Combo2String
{
get { return combo2String; }
set
{
if (combo2String != value)
{
combo2String = value;
this.FirePropertyChanged("Combo2String");
}
}
}
private string status;
public string Status
{
get { return status; }
set
{
if(status != value)
{
status = value;
this.FirePropertyChanged("Status");
}
}
}
[Edit]
~~~~~~~
In response to your comment, you need to implement
INotifyPropertyChanged
. That's an absolute requirement for MVVM approaches.