我正在尝试找出如何拥有 Image 在我的Windows Phone应用程序中控制用户在设置 - >主题 - >背景中选择的全局背景设置(“暗”或“光”)反转其颜色。

有帮助吗?

解决方案

没有内置的方式可以在框架内反转图像颜色。

相反,由于在手机上执行此操作的开销,您应该在设计/构建时间创建图像的两个版本,然后选择通过检测到从代码显示的版本 主题可见性和不透明度.

其他提示

我必须补充说,我最终所做的是马特写的延续。

  • 创建两个具有不同版本的图像(深色和光线)的不同图像,然后将它们放在完全相同的位置
  • 根据主题资源设置其可见性

代码看起来像这样:

<Image Height="30" HorizontalAlignment="Center" Margin="0,0,0,220" Name="imgDark" Stretch="Fill" Visibility="{StaticResource PhoneLightThemeVisibility}" VerticalAlignment="Center" Width="30" Source="/MyApplication;component/imageDarkTheme.png" />
<Image Height="30" HorizontalAlignment="Center" Margin="0,0,0,220" Name="imgLoading" Stretch="Fill" Visibility="{StaticResource PhoneDarkThemeVisibility}" VerticalAlignment="Center" Width="30" Source="/MyApplication;component/imageLightTheme.png" />

这个问题现在已有1.5岁了。但 这里 是做您想做的最简单的方法。给出的示例非常简单

<Button>
    <Image Stretch="None" Source="{Binding Converter={StaticResource ThemedImageConverter}, ConverterParameter={StaticResource PhoneBackgroundColor} }"
           DataContext="/WP7SampleProject4;component/Images/{0}/appbar.feature.camera.rest.png" />
</Button>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top