Reputation: 597
I am a beginner to wpf. I have an ellipse named ellipse1 and i fill it with white color. When i tap the ellipse it will change to red and if i again tap it it will again go back to white.. So i need to check the current color of the ellipse.
<Ellipse x:Name="Ellipse1"
Fill="White"
Tap="Ellipse1_Tapped"></Ellipse>
So how can i detect the current color of ellipse.
if(....)
{
Ellipse1.Fill = new SolidColorBrush(Colors.Red);
}
else
{
Ellipse1.Fill = new SolidColorBrush(Colors.White);
}
Upvotes: 0
Views: 1035
Reputation: 44038
public bool IsRed {get;set;}
void Ellipse1_Tapped(object sender, etcetera)
{
Ellipse1.Fill = IsRed ? Brushes.Red : Brushes.White;
IsRed = !IsRed;
}
Upvotes: 2