Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

TextBlock Color inside Button (with Blend 2015)

14 Feb 2018, 19:10

I have problem with states and Color for TextBlock.

I want change color and blend animation for TextBlock. I can easily set up everything in States. But when I run program from Blend, it crash, I get
An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll Additional information: Cannot animate '(0).(1)' on an immutable object instance.
I saw in Noesis Theme, there is ContentPresenter for text inside Button, but unfortunately can't change color for ContentPresenter inside Blend 2015 and I have to use TextBlock instead.
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: TextBlock Color inside Button (with Blend 2015)

14 Feb 2018, 19:17

Ok, I found this solution: I must convert color (TextBlock) to LocalValue (for Base state) and then crash dissapear.
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: TextBlock Color inside Button (with Blend 2015)

20 Feb 2018, 19:26

That's it, marking this as solved.

About animating ContentPresenter color, it cannot be done directly using Blend visual tools, but it can be changed in xaml code by animating the attached property TextElement.Foreground.

Who is online

Users browsing this forum: Google [Bot] and 1 guest