c# - How to bind ControlTemplate Enabled property to Opacity in WPF XAML -


How to expand a ControlTemplate in WPF inside XAM such as when applied to a button and the button is disabled If it is disabled then 0.5 opacity is disabled and once fade is enabled in 1.0 opacity.

This visual effect should work even when a parent is disabling.

You do not need the ControllTemplate for it You can complete it with just the styles below button style Has been applied to all buttons. This instability sets for 0.5 when IsEnabled is true and it automatically comes back to 1 when the trigger status is no longer applicable. If you are applying ControlTemplate in a style, you can add that trigger to that trigger. It works even when parents are disabled because IsEnabled inherited.

  & lt; window. Resources & gt; & Lt; Style TargetType = "{x: type button}" & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Control.IsEnabled" Value = "false" & gt; & Lt; Setter property = "control. Opacity" value = "0.5" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /Window.Resources>  

Or do you particularly need a control template solution?

Update

I do not think the template supports the banding converter, so if you want to do this in ControlTemplate, then you have sufficient low bonding statement in logical tree Need to use something like that.

> Opacity = {binding path = relationalSource = {RelativeSource templatedParent}, converter = {static resource bulletode double converter}

where the bulletoddblonver is an IVLUCover, which Returns 1 for right and 0.5 for false. If you can use styles then I still recommend the style approach. My faith is very simple.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -