Welcome to the Xceed Community | Help
Community Search  
More Search Options

White Background

Sort Posts: Previous Next
  •  07-01-2010, 5:46 PM Post no. 27378

    White Background

    I have downloaded the demo Themes. I am also pretty new to WPF. I am trying to add the themes to an application in code behind using the following.

     Collection<ResourceDictionary> mergedDicts = base.Resources.MergedDictionaries;

    Xceed.Wpf.Themes.Office2007.Office2007BlueResourceDictionary myDictionary = new Xceed.Wpf.Themes.Office2007.Office2007BlueResourceDictionary();

    myDictionary.LicenseKey = "XPT20-AUAKK-HAW1A-4NMA";

    Application.Current.Resources.MergedDictionaries.Add(myDictionary);

    But all I get is a white background. If i add

    this.SetResourceReference(BackgroundProperty, "Office2007BlueResources");

    Then i just get a black background no matter what theme I use.

    How can I fix this issue in code behind?

    Also is it possible in code behind to set the theme for the entire application?
     

    thanks

    Scott

    Filed under:
  •  07-02-2010, 2:14 PM Post no. 27391 in reply to 27378

    Re: White Background

    Ho Scott,

    To change the theme in code behind, you must be sure that if another theme was set previously, you must clear it first so that the resource names don't clash:

    ((Window)_keyboardWindow).Resources.Clear();

    Then, add it to your Window resources:

     Xceed.Wpf.Themes.Glass.GlassResourceDictionary dictionary = new Xceed.Wpf.Themes.Glass.GlassResourceDictionary();
      ((Window)_keyboardWindow).Resources.Add("someTestName", dictionary);

     


    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  07-04-2010, 3:42 AM Post no. 27393 in reply to 27391

    Re: White Background

    Ok sorry for being such a noob, but I dont know what the _keyboardwindow reference is or what the first param "sometestname" refers to? Also i would like to add the themes to the entire program. You know it would be real easy if you guys just had a small example WPF program available.
  •  07-05-2010, 10:45 AM Post no. 27398 in reply to 27393

    Re: White Background

    Hi,

    "someTestName" would be the key given to an added resource in the dictionary.  Since you are trying to add a MergedDictionary, you should rather use Application.Current.Resources.MergedDictionaries.Add as you were previously doing.  But you do need to make sure that the there are no naming conflicts from changing themes dynamically.

    From what I understand from your snippets, you are using the current application's resources to add you theme dictionary.  To make this work, you can replace ((Window)_keyboardWindow) by Application.Current.  This will make sure that you are currently using your application's resources rather than the window's so that those resources can be used throughout your whole application.  If you have no other resources in your application's resourceDictionary, you can clear the resources and add the new mergedDictionary by using Application.Current.Resources.Clear() beforehand.


    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  07-06-2010, 4:33 PM Post no. 27419 in reply to 27398

    Re: White Background

    thanks for the reply. i have this part figured out, but if you notice in my original post i have to set the background property to the resouce. why doesnt the theme set the background to the correct color? or I should say what am i doing wrong?

    thanks

    Scott

  •  07-07-2010, 9:47 AM Post no. 27429 in reply to 27419

    Re: White Background

    Hi Scott,

    Due to some limitations in the framework, it is a known issue that when affecting the theme through code, the background of the application does not get affected properly even when the ResourceDictionary is added to the application's resources.  To fix this, you will have to set the background explicitly.  In example, for the Office2007Blue theme, you would need to add this line :

    (yourWindow).Background =  Xceed.Wpf.Themes.Office2007.Office2007BlueResources.ApplicationBackgroundBrush;


    François Dubé
    - Technical Designer -
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.