DynamicResource does not work, but does StaticResource do?

Here is the scenario:

1) Open Visual Studio 2008, create a new project ...

2) Select the WPF User Control Library as the project type

3) Open the Generic.xaml resource dictionary located in the Themes folder

4) Add a simple brush, for example:

<SolidColorBrush x: Key = "BackgroundBrush" Color = "Yellow" / ">

5) Change the Background property of the nested Borer control to

Background = "{TemplateBinding Background}"

to

Background = "{DynamicResource BackgroundBrush}"

Now, when you compile and use this control in any project, the background will NOT be yellow. BUT if you change the background property as StaticResource as such

Background = "{StaticResource BackgroundBrush}"

... . ? StaticResource, DynamicResource???

+3
1

Xaml, .

MSDN DynamicResource , , , ( ), .

C.

0

Source: https://habr.com/ru/post/1725085/


All Articles