Reputation: 619
I have a list of 10 Buttons,in which I want to apply a specific Style when I select that Button,I did like that:
private bool button1WasClicked = false;
private bool button2WasClicked = false;
private bool button3WasClicked = false;
.....
private void button1_Click(object sender, EventArgs e)
{
button1WasClicked = true;
}
private void button2_Click(object sender, EventArgs e)
{
button2WasClicked = true;
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (button1WasClicked)
{
apply the style on Button1
button1WasClicked = false;
}
if (button2WasClicked)
{
apply the style on Button2
button2WasClicked = false;
}
...... //complete the list of other buttons
}
My question is,is there any other method I can use to apply the Style on the selected button of my 10 Buttons not the others
I hope someone can help me here.. thanks
Upvotes: 0
Views: 38
Reputation: 3568
Theres is the ToggleButton, which comes with a Checked property and has different VisualStates for Checked and Unchecked.
Upvotes: 1