次の方法で共有


DynamicResourceHandler 拡張機能

DynamicResourceHandler 拡張機能は、アプリのテーマ設定に使用できる IDynamicResourceHandler の構成をサポートする一連の拡張メソッドを提供します。

この拡張機能では、次のメソッドが利用できます。

DynamicResource

DynamicResource メソッドは、IDynamicResourceHandler を実装するコントロールに DynamicResource プロパティを設定します。

次の例では、Label.TextColorPropertyResourceDictionary キー TextColor にバインドします。

new Label().DynamicResource(Label.TextColorProperty, "TextColor");

DynamicResources

DynamicResources メソッドは、IDynamicResourceHandler を実装するコントロールに複数の DynamicResource プロパティを設定します。

次の例では、Label.TextColorPropertyResourceDictionary キー TextColor にバインドし、さらに Label.FontFamilyPropertyResourceDictionary キー FontFamily にバインドします。

new Label().DynamicResources(Label.TextColorProperty, "TextColor", 
                                Label.FontFamilyProperty, "FontFamily");