C# 中的 Metro Tile 通知
我正在尝试用 C# 将一个简单的 Windows 8 Metro 风格应用程序与磁贴通知组合在一起,但我似乎无法让它们工作。
我还不太清楚更新磁贴通知的代码应该驻留在哪里。我查看了 Javascript 示例,但我没有看到它在 C# 应用程序中如何工作。有没有人获得一些示例代码或有关 C# Metro 应用程序中应在何处进行图块更新的快速提示?
I'm trying to put together a simple Windows 8 metro style app in c# with tile notifications but I can't seem to get them working.
What I can't quite figure out yet is where the code to update the tile notifications should reside. I've had a look at the Javascript sample, but I'm not seeing how that works in a C# app. Has anyone got some sample code or a quick tip on where tile updates should happen in a C# metro app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的理解是,每个应用程序都会自行决定在哪里执行此操作。通常,只要您还使用相同的数据更新正常的 UI,您就会执行此操作 - 例如,如果您的应用程序是 RSS 阅读器,并且您刚刚下载了要显示的新项目,那么您还可以通过以下方式更新磁贴:发布通知。在示例 JavaScript 应用程序中,为了方便起见,这是通过控件的事件处理程序完成的。
至于更改磁贴的代码,它应该与 JavaScript 版本几乎相同,因为在这两种情况下您都使用 Windows.UI.Notifications 命名空间。以下是一个非常简单的 C# 应用程序,当您单击按钮时,它会更新磁贴。 XAML:
和背后的代码:
不要忘记您需要一个宽磁贴来显示文本 - 要获得它,请在 Package.appxmanifest 中为“宽徽标”设置一些图像。
My understanding is that every app decides where to do this for itself. Normally, you'd do it whenever you're also updating your normal UI with the same data - e.g. if your app is an RSS reader, and you've just downloaded a new item to display, that's where you also update your tile by posting a notification. In the sample JavaScript app, this is done from event handlers for controls for the sake of convenience.
As for the code to change the tile, it should be almost identical to JavaScript version, since in both cases you use Windows.UI.Notifications namespace. Following is a very simple C# app that updates the tile when you click the button. XAML:
and code behind:
Don't forget that you need a wide tile for text to show up - to get it, set some image for "Wide Logo" in Package.appxmanifest.
确保将初始旋转更改为横向,为 Widelogo 设置一些图像,并使用此方法设置文本和到期时间。
这是详细说明http://www.amazedsaint。 com/2011/09/hellotiles-simple-c-xaml-application.html
Make sure you change the Initial rotation to Landscape, set some image for Widelogo, and use this method to set the text along with an expiry.
Here is a detailed explanation http://www.amazedsaint.com/2011/09/hellotiles-simple-c-xaml-application.html