c# - Standard way dynamically set theme based Images for Windows Phone -


i setting images theme in mainpage.xaml.cs

public mainpage() {     initializecomponent();     setthemeicons(); }  private void setthemedicons() {     uri u;     if ((visibility)application.current.resources["phonedarkthemevisibility"] == visibility.visible)     {         u = new uri("/images/img_dark.png", urikind.relative);     }     else     {         u = new uri("/images/img_light.png", urikind.relative);     }     btnsessionsearch.source = new bitmapimage(u); } 

this seems inferior coding me. main reason have every image in application going theme sensitive.

ideal way bind image directly in xaml. how theme aware ?

take @ themedimageconverter can use in way:

<image stretch="none" source="{binding converter={staticresource themedimageconverter}, converterparameter={staticresource phonebackgroundcolor}}" datacontext="/wp7sampleproject4;component/images/{0}/appbar.feature.camera.rest.png" /> 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -