Page 1 of 1

TextBlock Color inside Button (with Blend 2015)

Posted: 14 Feb 2018, 19:10
by Wanderer
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.

Re: TextBlock Color inside Button (with Blend 2015)

Posted: 14 Feb 2018, 19:17
by Wanderer
Ok, I found this solution: I must convert color (TextBlock) to LocalValue (for Base state) and then crash dissapear.

Re: TextBlock Color inside Button (with Blend 2015)

Posted: 20 Feb 2018, 19:26
by sfernandez
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.