componentresourcekey

ComponentResourceKey as DynamicResource problem

别来无恙 提交于 2019-12-24 00:23:58
问题 I'm seeing some unexpected behavior using ComponentResourceKey. The problem came up because I was using names used in the SystemColors class. Consider the following code: First I expose a ComponentResourceKey in a as a static property: public enum ColorKeys { ControlColor } public class MyColors { public static ComponentResourceKey ControlColorKey { get { return new ComponentResourceKey(typeof(MyColors), ColorKeys.ControlColor); } } } Using the key in markup to assign a resource to that key

How do I get the actual resource from a ComponentResourceKey?

吃可爱长大的小学妹 提交于 2019-12-22 11:17:35
问题 I have a ComponentResourceKey defined in my resource dictionary like this: <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:Resources}, ResourceId=BaseControlStyle}" TargetType="{x:Type FrameworkElement}"> <Setter Property="Margin" Value="4,4,0,0" /> </Style> I have a static class that I use as a shortcut to provide the resource keys liek this: public class Resources { public static ComponentResourceKey BaseControlStyleKey { get { return new ComponentResourceKey(typeof

WPF StaticResource works, DynamicResource doesn't

心已入冬 提交于 2019-12-04 19:31:42
问题 I have been trying for a day now, to no avail, to create a bunch of brushes in the theme then using them with DynamicResource in a custom control. What I did is this: create the theme generic.xaml which contains styles (works) add a dictionary to merge in generic.xaml to contain brushes used in the application (works) make brushes have ComponentResourceKey keys (works) make control use brushes as static resource (works) make control use brushes as dynamic resource (DOESN'T WORK, the resource

WPF StaticResource works, DynamicResource doesn't

こ雲淡風輕ζ 提交于 2019-12-03 12:40:21
I have been trying for a day now, to no avail, to create a bunch of brushes in the theme then using them with DynamicResource in a custom control. What I did is this: create the theme generic.xaml which contains styles (works) add a dictionary to merge in generic.xaml to contain brushes used in the application (works) make brushes have ComponentResourceKey keys (works) make control use brushes as static resource (works) make control use brushes as dynamic resource (DOESN'T WORK, the resource trace source says as much: System.Windows.ResourceDictionary Warning: 9 : Resource not found; ) add in

Getting a ComponentResourceKey to Work?

穿精又带淫゛_ 提交于 2019-11-28 11:47:28
I am building a WPF app with several assemblies, and I want to share a resource dictionary among them. That requires a ComponentResourceKey . I have built a small demo to test out the CRK, and I can't seem to get it working. My demo has two projects, a WPF project called Demo , and a DLL called Common . The Common project has a folder called Themes . It contains my resource dictionary, generic.xaml . Here is the text of the Resource dictionary: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns