5

私のアプリケーションは、別々のファイルで定義されたリソースディクショナリからすべての文字列をロードしXAMLます。DynamicResource実行時にキーが存在しない可能性があります。

<CheckBox Content="{DynamicResource myKeyThatIsMissing}"/>

通常のバインディングには、次のように使用できるフォールバック値があります。

Text="{Binding StringToShow, FallbackValue=DefaultValue}

DynamicResourceリソースキーが存在しない場合に使用されるプロパティセットのデフォルトのフォールバック値を持つことは可能ですか?

4

1 に答える 1

1

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.

于 2015-05-28T13:45:49.230 に答える