I'm trying to create a method of changing themes in my program using WPF. I have that part working, so the next step is to try to automate as much as I can. Currently, I have the following in my project. Each file contains a ResourceDictionary that I'm using to set the theme for my WPF application.
When the program is running, I'm making a menu that will contain the theme's as a set of menu items. Currently I'm using the following code to populate that list.
private void LoadSkinsList()
{
List<string> assembies = new List<string>();
assembies.Add(@"Skins/Default/Resources.xaml");
assembies.Add(@"Skins/Black/Resources.xaml");
assembies.Add(@"Skins/Green/Resources.xaml");
foreach (string name in assembies)
{
MenuItem menuItem = new MenuItem();
menuItem.Header = name;
menuItem.Command = SelectTheme;
menuItem.CommandParameter = menuItem;
ThemeMenuItems.Add(menuItem);
}
}
What I would like to do is find the Folders Black,Default and Green via using code, I'm happy to find the paths to all the files in the the folders, then shred the info.
I'm not just not sure how to find the folders or files in the first place.
The Resources.xaml files are all compiled into the project using the Build Action Page.
Any ideas how I can replace the block of code.
assembies.Add(@"Skins/Default/Resources.xaml");
assembies.Add(@"Skins/Black/Resources.xaml");
assembies.Add(@"Skins/Green/Resources.xaml");
with something that will find the resources via code?
Aucun commentaire:
Enregistrer un commentaire