Getting a ComponentResourceKey to Work?

后端 未结 1 1569
逝去的感伤
逝去的感伤 2020-12-10 22:46

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 tes

相关标签:
1条回答
  • 2020-12-10 23:14

    I found my problem. I was confusing the Component Resource Key with the Resource ID inside the resource dictionary. In other words, my Component Resource Key was the same as the Resource ID. I changed my static property to this:

    public static ComponentResourceKey RedBrushKey
    {
        get {return new ComponentResourceKey(typeof(SharedResources), "RedSolidBrush"); }
    }
    

    The property name is now RedBrushKey, instead of RedSolidBrush. And the key is now working.

    0 讨论(0)
提交回复
热议问题