i had some trouble generating WPF styles containing Triggers from C# code.
Here’s the WPF code i want to generate trough C#.
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BitmapEffect">
<Setter.Value>
<OuterGlowBitmapEffect GlowColor="Gold" GlowSize="10" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
I alredy tried to generate like this :
Style style = new Style();
Trigger trigger = new Trigger();
Setter setter = new Setter();
style.Triggers.Add(trigger);
trigger.Property = (DependencyProperty.Register("IsMouseOver", Type.GetType("IsMouseOver"), Type.GetType("Canvas"))); //Line not tested
//trigger.Setters.Add(new Setter(new BitmapEffect()); //Line not working
But i could not figure out how to use trigger.Setters with a BitmapEffect
Thanks you in advance!
The direct translation would be:
This can be cleaned up to:
But this is based on your coding style.