Is there a way to save a default value for dynamic ressources in a custom control library?
I have created a custom control library and therefore I use a default Style which resides in the Generic.xaml file. This "default style" uses references to dynamic resource markers (see in the example).
<Style TargetType="{x:Type local:BorderlessWindow}"> <Setter Property="Foreground" Value="{DynamicResource ForegroundColor}" /> <Setter Property="Background" Value="{DynamicResource BackgroundColor}" /> <Setter Property="TitleBackground" Value="{DynamicResource AltBackgroundColor}" /> <Setter Property="Template" Value="{StaticResource DefaultBoderlessWindowTemplate}" /> </Style> Everything is working as expected if I reference to my custom control library in a new project and add the dynamic resource markers in this new projects app.xaml but the values are empty if I do not do this.
So I want some kind of default values. In other words:
"Take the value of {DynamicResource ForegroundColor} or if this do not exist blue."
I thought I just have to add the default values in the Generic.xaml (MergedDictionary) but this wont do the job. Does anyone have a solution?
The only solution I can think about is to replace the dynamicResource markers with the concret (default) values (e.g. blue, green, black) and handle resources in the "consuming" app if you know what I mean.
MarkupExtensionused instead ofDynamicResource, where you check for availability of resource at the moment when xaml is loaded/parsed, unfortunately I don't have time to quickly test this approach today.