Silverlight – Change TextBlock Color from CS (Windows Phone 7)

I am a new developer of Windows Phone 7. I have TextBlock Text = “{Binding MyDate}” on the MainPage.xaml page.

How Change the color of this TextBlock from MainPage.xaml.cs?

First, you need to specify an x:Name attribute for the TextBlock element, such as X:NAME = ” myTextBlock”. After this is done, the TextBlock can be used in the code-behind as a field with the same name as x:Name.

To set the foreground color of the TextBlock, you can use something similar

myTextBlock.Foreground = new SolidColorBrush(someColor);

I am a new developer of Windows Phone 7. I On the MainPage.xaml page, there is TextBlock Text = “{Binding MyDate}”.

How to change the color of this TextBlock from MainPage.xaml.cs?

First, you need to specify an x:Name attribute for the TextBlock element, for example, X:NAME = “myTextBlock”. After this operation is completed, the TextBlock is in the code-behind Can be used as a field with the same name in x:Name.

To set the foreground color of the TextBlock, you can use something similar

< pre>myTextBlock.Foreground = new SolidColorBrush(someColor);

Leave a Comment

Your email address will not be published.