WPF Dynamic Resource: Warning Message - "The resource 'resource' could not be resolved."
Basically, I have a UserControl that uses a DynamicResources. The application compiles and runs fine using that resource, but it's a bit annoying to see this warning message. It makes me wonder if I'm doing it right and it's just a false positive, or if I'm doing it wrong and happen to slip through the cracks in it working.
<Grid Background="{DynamicResource AppDefaultBackgroundColor}">
...
</Grid>
So, if I used it correctly, how can I get rid of this warning message?
If I did not use it appropriately, what should it look like so I don't get a warning?P.S. My application works and r开发者_Python百科uns fine, but I prefer to not have any compilation warnings when compiling.
You can map your resource like this
<Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\Resources\Theme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Resources>
Theme.xaml must contain 'AppDefaultBackgroundColor' like this
<Color x:Key="AppDefaultBackgroundColor">#FF77C6FB</Color>
精彩评论