My application loads all strings from resource dictionaries defined in separate XAML files. It is possible that the DynamicResource key will not exist during run-time.
<CheckBox Content="{DynamicResource myKeyThatIsMissing}"/>
In a normal binding there is a Fallback value that can be used like this:
Text="{Binding StringToShow, FallbackValue=DefaultValue}
Is it possible to have a default Fallback value for a property set with a DynamicResource that is used if the resource key does not exist?
The class System.Windows.DynamicResourceExtension is unsealed so perhaps you can extend it and add the logic you desire by overriding the ProvideValue method.
Unfortunately the default implementation returns an instance of the internal ResourceReferenceExpression class, so you may have to do some reflection or other magic to make this work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With