New Here?
My name is Nir and I'm the founder of Nbd-Tech, this blog is about things that interest me, so you can find posts on productivity, running a software company and obscure technological topics.
If you like what you read you can
subscribe to the blog feed or
follow me on twitter.
The biggest limitation of triggers in WPF is that except for EventTrigger they only work in styles and templates, I always find myself in situation where just putting a trigger directly in my window or control class will save me a lot of work – but it just can’t be done.
Just a few days ago I accidently run across a simple workaround, this is probably the best kept secret in WPF and is hidden in a little blue box at the end of this post on animation in M-V-VM.
Just define a DataTemplate with whatever you want to show and your triggers (DataTemplate supports all trigger types: Trigger, DataTrigger and EventTrigger) and drop the data template anywhere by using this XAML:
<ContentPresenter ContentTemplate="{StaticResource myTemplate}" Content="{Binding}" />
posted @ Monday, March 16, 2009 5:06 PM