UWPアプリを開発していて、テンプレート10を使用しています。 私は黒い画像と白い画像を持っています。ユーザーが暗いテーマを選択したとき、私はしたい、白画像を表示し、ユーザーは、光をテーマに黒画像を表示選択すると、exemple:アプリケーションのテーマに応じて画像を表示
if(dark theme)
{
white image;
}
else
{
black image;
}
UWPアプリを開発していて、テンプレート10を使用しています。 私は黒い画像と白い画像を持っています。ユーザーが暗いテーマを選択したとき、私はしたい、白画像を表示し、ユーザーは、光をテーマに黒画像を表示選択すると、exemple:アプリケーションのテーマに応じて画像を表示
if(dark theme)
{
white image;
}
else
{
black image;
}
あなたはthis.RequestedTheme
を使用して、現在のRequestedThemeを取得し、ElementTheme.Light
またはElementTheme.Dark
とそれを比較することができます
方法1
if (this.RequestedTheme == ElementTheme.Light)
BackgroundImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/BlackImage.png"));
else
BackgroundImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/WhiteImage.png"));
方法2
BackgroundImage.Source = (this.RequestedTheme == ElementTheme.Light)? new BitmapImage(new Uri("ms-appx:///Assets/BlackImage.png")): new BitmapImage(new Uri("ms-appx:///Assets/WhiteImage.png"));
私はその質問を考えません。私はあなたがドキュメントを読むことができると思う:https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/xaml-theme-resources – lindexi
[this](https://stackoverflow.com)/a/44600513/7331395)回答が有効ですか? –