Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to put Setter elements inside EventTrigger?

Working on a WPF application, I started working on a custom ControlTemplate. I reached the point where I need to change some control properties when an event occurs.

For this purpose, there are Setter elements. Seems all good, but I cannot use them inside EventTrigger elements. For example, if a simple Trigger, that can be bound to control properties, is used then Setter elements can be used inside. However, I do not want to bind to a property change but rather to an event.

Is there a way to do this in pure XAML or will I have to work in the code-behind?

like image 833
Den Delimarsky Avatar asked May 09 '10 14:05

Den Delimarsky


1 Answers

You can put a StoryBoard there, and have it start an ObjectAnimationUsingKeyFrames that will "animate" your properties instantly to the target state. If your properties are double or Color - even better: you will be able to actually make them transition smoothly using DoubleAnimation or ColorAnimation respectively.

I think this is a bit of an overkill, but if you want to use pure XAML, this is possible to do.

like image 107
Fyodor Soikin Avatar answered Oct 13 '22 00:10

Fyodor Soikin