如何使应用程序栏中的图标根据当前主题而变化?
在 WP7 应用程序中,使应用程序栏中的图标与当前主题(浅色/深色)相匹配的首选方法是什么?我真的需要使用“hack”来检测当前主题,并据此设置图标,还是有更好的方法?
In WP7 apps, what is the preferred way to make the icons in the Application Bar match the current theme (light/dark)? Do I really need to use the "hack" to detect the current theme, and set the icons based on that, or is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用默认(白色)图像,或创建类似的透明白色 PNG 图像,则无需执行任何操作;操作系统会为您处理它。
If you use the default (white) images, or create similar PNG images that are white on transparent, then you don't need to do anything; the operating system handles it for you.
只需使用 PhoneDarkThemeVisibility 资源:
根据用户设置,仅显示两个项目之一。它有芒果版本。
另一种选择是仅使用一个配置了 OpacityMask 的图像。您可以在此处了解更多信息。
Just use PhoneDarkThemeVisibility resource:
Depending on user settings only one of two items will be displayed. It is available in Mango.
Another option is to use only one image with OpacityMask configured. You can find out more about it here.
我建议您存储两组图标(深色和浅色),并在后面的代码中动态创建应用程序栏。然后让用户可以选择他们想要的主题,并使用简单的 if...else 语句处理加载的图标。
现在,为了确定用户正在使用哪个主题,您可以检查“phonelightthemevisibility”资源。检查该资源是否可见。
让我知道这是否有帮助。
I would suggest you store both sets of icons, dark and light, and create the app bar dynamically in the code behind. Then give the user the option to choose which theme they would like and handle the icons that get loaded using a simple if...else statement.
Now in order to determine which theme the user is using you can check the "phonelightthemevisibility" resource. Check if that resource is visible.
Let me know if this helps.