I have several RadioButtons and CheckBoxes in my application and I would like to trigger an event when they are checked. I want an image to pop up on top of another one.
<ListBox Grid.ColumnSpan="3" HorizontalAlignment="Left" Height="102" Margin="28,58,0,0" VerticalAlignment="Top" Width="128" Background="{x:Null}" BorderBrush="{x:Null}">
<RadioButton x:Name="classicWhiteRadio" Content="Classic White" HorizontalAlignment="Left" VerticalAlignment="Top" Checked="classicWhiteRadio_Checked"/>
<RadioButton x:Name="wholeGrainRadio" Content="Whole Grain" HorizontalAlignment="Left" VerticalAlignment="Top" Checked="wholeGrainRadio_Checked"/>
<RadioButton x:Name="tomatoBasilRadio" Content="Tomato Basil" HorizontalAlignment="Left" VerticalAlignment="Top" Checked="tomatoBasilRadio_Checked"/>
<RadioButton x:Name="sweetOnionRadio" Content="Sweet Onion" HorizontalAlignment="Left" VerticalAlignment="Top" Checked="sweetOnionRadio_Checked"/>
<RadioButton x:Name="garlicButterRadio" Content="Garlic Butter" HorizontalAlignment="Left" VerticalAlignment="Top" Checked="garlicButterRadio_Checked"/>
</ListBox>
So first of all I set the image's visibility to Hidden.
<Image Name="classicTomatoSauce" Grid.Column="4" Margin="362,138,270,123" Source="classicTomatoSauce.gif" Stretch="Fill" Grid.ColumnSpan="2" Visibility="Hidden"/>
<Image Name="chipotleSauce" Grid.Column="4" Margin="359,142,267,127" Source="chipotleSauce.gif" Stretch="Fill" Grid.ColumnSpan="2" Visibility="Hidden"/>
<Image Name="texasBBQSauce" Grid.Column="4" Margin="360,138,270,121" Source="texasBBQSauce.gif" Stretch="Fill" Grid.ColumnSpan="2" Visibility="Hidden"/>
<Image Name="pestoSaucee" Grid.Column="4" Margin="360,138,275,120" Source="pestoSauce.gif" Stretch="Fill" Grid.ColumnSpan="2" Visibility="Hidden"/>
<Image Name="honeyGarlic" Grid.Column="4" Margin="356,135,267,121" Source="honeyGarlic.gif" Stretch="Fill" Grid.ColumnSpan="2" Visibility="Hidden"/>
Then I trigger each radio/check box to change the image's visibility like so (when checked):
private void classicWhiteRadio_Checked(object sender, RoutedEventArgs e)
{
basePizza.Visibility = System.Windows.Visibility.Visible;
}
private void wholeGrainRadio_Checked(object sender, RoutedEventArgs e)
{
basePizza.Visibility = System.Windows.Visibility.Visible;
}
private void tomatoBasilRadio_Checked(object sender, RoutedEventArgs e)
{
basePizza.Visibility = System.Windows.Visibility.Visible;
}
private void sweetOnionRadio_Checked(object sender, RoutedEventArgs e)
{
basePizza.Visibility = System.Windows.Visibility.Visible;
}
private void garlicButterRadio_Checked(object sender, RoutedEventArgs e)
{
basePizza.Visibility = System.Windows.Visibility.Visible;
}
And for some reason they still do not pop up when I test run the application. What could cause this?
Aucun commentaire:
Enregistrer un commentaire