hi all,
i got a WPF sample which selects the style dynamically. i.e it asks for the "style.xaml" file and assignes that xaml file to the resources. like in the code given below.
OpenFileDialog
dialog = new OpenFileDialog();dialog.InitialDirectory =
@"..\..\";dialog.Filter =
"XAML Files (*.xaml)|*.xaml|All Files (*.*)|*.*";dialog.FilterIndex = 0;
if ((bool)dialog.ShowDialog()){
using (FileStream fs = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read)){
ResourceDictionary dictionary = (ResourceDictionary)XamlReader.Load(fs); this.Resources = dictionary;fs.Close();
}
now what i want is, i want to select the style dynamically without selecting the xaml file but something like this::
switch (i)
{
case 1: this.Resources = (ResourceDictionary) this.TryFindResource("Style1.xaml"); break; case 2: this.Resources = (ResourceDictionary) this.TryFindResource("Style2.xaml"); break; default: this.Resources =(ResourceDictionary) this.TryFindResource("Style.xaml"); break;}
where value of i is dynamic. it will be very greatful if anyone can answer.
Thanks in advance
bye

selecting the style dynamically