I have public class MyControl : ContentControl
in wchich i have definitions of control and events correspondi开发者_运维知识库ng with it.
This control works fine, but when is disabled it looks still like enabled. I would like to do something like if control.isenabled = false
then control.opacity = 0.5;
How can i do it?
In WPF for such things triggers are used.
<MyControl>
<MyControl.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value="0.5" />
</Trigger>
</MyControl.Triggers>
</MyControl>
As you said - this trigger don't work - I have checked...
But I have found solution - in OnApplyTemplate method I have added few lines:
public override void OnApplyTemplate()
{
//...
if (this.IsEnabled == false)
{
this.Opacity = 0.4;
}
}
精彩评论