I am currently creating an application consisting of several components, each of which is essentially a WPF user control with a little C # code around it for the plugin system to work (using MEF).
The problem I am facing is that each component must contain an icon and for convenience, I have defined it as System.Windows.Media.Brush , so I can just use the DrawingBrush exported from Design there. Now I need to access this part of XAML from non-WPF C #, where I have a terrible workaround for creating a user control and requesting it for a resource:
private Brush CachedIcon = null; public override Brush Icon { get { if (CachedIcon == null) { CachedIcon = (Brush)(new BlahControl().TryFindResource("Icon")); } return CachedIcon; } }
I could not find a way to read this resource (which is a .xaml file and specified in a ResourceDictionary in a user control) from a regular C # class. Everything that belongs to WPF has a good TryFindResource method, but how to do it otherwise? I do not want the XAML file with the icon to lie around the non-built.
c # wpf embedded-resource
Joey
source share