c# - How to reset a WPF control's default opacity toggling via IsEnabled after setting opacity explictly? -
when disable control (button), dark hard read text.
so using extension method set opacity 1.0 (100%) can read easily, when disabled:
public static void isenabledspecial(this system.windows.uielement control, bool isenabled) { control.isenabled = isenabled; control.opacity = 1.0; // makes disabled control more readable }
normally, when opacity not explicitly set wpf control, appears toggle between 1.0 (100%) when control enabled , 0.35 (35%) when control disabled.
once explicitly set opacity using extension method, control thereafter ceases toggle between 1.0 , 0.35 when set isenabled without extension method. gets "stuck" @ 1.0 (100%), when isenabled set false;
after set opacity, how can later reset control normal opacity toggling between 1.0 , 0.35?
the changing of opacity
being done through triggers. setting value directly, overriding value may produced style or triggers. not way go doing sort of thing. should using styles , triggers of own.
however, may able achieve want clearing value assigned opacity
:
control.clearvalue(uielement.opacityproperty);
Comments
Post a Comment