If you fed up searching for such an option,here is the solution with 3 simple steps...
- Add a file named generic.xaml.cs
- Right click on themes folder and select new class
- Name it as generic.xaml.cs
- Change the definition of the class inside generic.xaml.cs as
partial class generic :ResourceDictionary //This class should inherit from ResourceDictionary - Link this code behind file to Gereric.xaml by using x:Class
<ResourceDictionary
x:Class="MyControls.themes.generic" //The class name should be complete.ie with namespace
Now you can write code for your generic.xaml elements in the generic.xaml.cs file.
The same method can be applied if you want to write code behind for any other xaml resource file.
A sample is attached here
This offers an easy way to get style resources stored in generic.xaml.
ReplyDeleteMyControls.themes.generic objGeneric = new MyControls.themes.generic();
Me.Style = objGeneric["myStyle1"];
Cool, thanks
ReplyDelete