Ranjeet Jain
Ranjeet Jain

Reputation: 11

Check foreground color of textblock

I want to check my foreground color of my tapped textblock..

The code I have used is

If(textblock.foreground.equals(system.media.color.fromargb(100,0,255,0)))
Messagebox.show("got it ")";

This code is not working can any one help me??

Edited :- I want to check the color of 4 textblock.. I know the index value of the the textblock..

Upvotes: 1

Views: 59

Answers (1)

Fatih Dumanlı
Fatih Dumanlı

Reputation: 36

Try this:

 private void TextBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        if(((sender as TextBlock).Foreground as SolidColorBrush).Color.Equals(Colors.Green))
        {
            MessageBox.Show("It is green");
        }
    }

Upvotes: 1

Related Questions