Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1090
Dynamic Menu In Ribbon/Changing Themes
posted

Hey,

 I am trying to set up a menu in my ribbon that allows my users to dynamically choose a theme.  I didn't have any luck finding anything built in to do this (does something like this exist?) so I tried something on my own.  Attached is a sample project

 Basically I used the ThemeManager class to get a list of the themes, created model objects from the themes, put them on a view model, and bound the ItemsSource of the application menu to ViewModel.Themes (I put the button tools directly in the application menu in my sample code so that it's quicker to get to -- once its working I would want it in a menu item in the application menu).  I set up a DataTemplate to create button tools for each of my theme model objects.  The button tools are bound to a ChangeThemeCommand, passing the theme model as the argument to the command.

 My questions are:

1.) Is the way that I set up the DataTemplate/ItemsSource binding to fill the menu and bind to my command correct or is there some sort of bug with command binding?

The command binding sort of works, but is extremely flakey.  If I click the Fall theme one time, it does nothing.  If I keep clicking it, it eventually works.  It's not hitting my command's CanExecute methods so it feels like the command isn't bound for the first few clicks? 

Being able to set up dynamic buttons bound to commands is particularly important to me because I know of a few other places where I'll need to do this.

2.) Is the way that I change themes valid (in the ChangeThemeCommand class)?

I was guessing when I set up that chunk of code.  Basically, I want as many of the controls as possible to take on the theme that the user chooses and the rest to have some sort of default theme (ie if the new theme doesn't include them).

 

Thanks

ThemeSample.rar
Parents Reply Children
No Data