binding - WPF color effect for UI element -


how add color effect ui element?

for example, should more yellow, pixels have more yellow color. need make black form bit white, while inactive.

based upon clarifications, effect want achieve place translucent veneer on client area, , adjust appearance programmatically. technique use wpf grid. control allows layering. here's xaml fragment sets 2 layers...

<window.resources>     <solidcolorbrush color="yellow" x:key="myveneerbrush"/> </window.resources> <grid>     <grid background="{staticresource myveneerbrush}" opacity="{binding veneeropacity}"/>     <grid>         <dockpanel>             <!--layout goes here-->             <textblock text="hello" fontsize="52"/>         </dockpanel>     </grid> </grid> 

the first layer contains veneer , second layer contains content. opacity on first layer can set 0 (totally transparent) 1 (totally visible), , in between values give translucent quality. need write viewmodel along these lines...

public class viewmodel :inotifypropertychanged {     public viewmodel()     {         turnveneeron();     }     private void turnveneeroff()     {         veneeropacity = 0;     }     private void turnveneeron()     {         veneeropacity = 0.4;     }     private double _veneeropacity;     public double veneeropacity     {         [debuggerstepthrough]         { return _veneeropacity; }         [debuggerstepthrough]         set         {             if (value != _veneeropacity)             {                 _veneeropacity = value;                 onpropertychanged("veneeropacity");             }         }     }     #region inotifypropertychanged implementation     public event propertychangedeventhandler propertychanged;     protected virtual void onpropertychanged(string name)     {         var handler = system.threading.interlocked.compareexchange(ref propertychanged, null, null);         if (handler != null)         {             handler(this, new propertychangedeventargs(name));         }     }     #endregion } 

this vm exposes property binds view , controls opacity of first layer in xaml. there's 2 indicative methods thrown in started.

you need experiment window background , brush , various levels of opacity exact effect after, there's enough here how works.

the key use grid's layering capability.


Comments