Click here to Skip to main content
15,882,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

thanks for all the huge responses.
This time i am having a problem in styles.
I have to styles.i want them to get loaded them dynamically on fire of an event like combo. when i select user defined theme1 then all the controls takes the styles of theme one and when i select theme2 then all the controls takes the respective styles. i am able to set the style for one style as well as i am able to use all the silverlight theme dynamically.but for selecting and setting a particular theme i dont know how to do that.

Some body pls help.


i have written this code below and finding an exception which say
"An item with the same key has already been added".


void GetThemes(string s)<br />
        {<br />
            StreamResourceInfo sri = Application.GetResourceStream(new Uri(string.Format("Test;component/{0}.xaml",s), UriKind.Relative));<br />
            StreamReader sr = new StreamReader(sri.Stream);<br />
            XElement element = XElement.Parse(sr.ReadToEnd());<br />
            List<Theme> themeSettings = new List<Theme>();<br />
            IEnumerable c1 = from el in element.Elements() select el;<br />
            <br />
            foreach (XElement ele in c1)<br />
                themeSettings.Add(new Theme { Key = ele.FirstAttribute.Value, Value= ele.ToString() });<br />
            IsolatedStorageSettings.ApplicationSettings.Add(string.Format("{0}Theme",s), themeSettings);                        <br />
        }


the exception comes in the last line ie
IsolatedStorageSettings.ApplicationSettings.Add(string.Format("{0}Theme",s), themeSettings);
Posted
Updated 30-Jun-11 0:06am
v2

1 solution

There is an excellent tutorial on how to do this here Dynamic Styles[^].

Hope this helps
 
Share this answer
 
Comments
Saumya J Pandey 30-Jun-11 8:16am    
thanks Wayne, this tutorial is really excellent. i was working on this since a week and finally you solved it.. thanks a ton
Wayne Gaylard 30-Jun-11 8:25am    
Glad I could help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900