【问题标题】:How to write a InAppNotification helper, so I can call it everywhere如何编写一个 InAppNotification 助手,这样我就可以在任何地方调用它
【发布时间】:2020-05-26 20:53:34
【问题描述】:

目前,我在需要祝酒的每一页中都使用Microsoft.Toolkit.Uwp.UI.Controls.InAppNotification。喜欢,

<Page>
    <Grid>

        //some else code
        <controls:InAppNotification />
    </Grid>
</Page>

这很烦人,我必须一页一页地写。 如何将它包装在用户控件或助手中,所以我只需要调用助手即可。

谢谢。

【问题讨论】:

    标签: uwp uwp-xaml


    【解决方案1】:

    请查看此case 回复,根据您的要求,您可以基于Popup 类为您的UWP 应用制作HUD,该类可以在没有xaml 的代码中实现。您也可以使用上述控件,但需要编辑应用程序的导航架构。例如,如果您使用NavigationView 作为基础architecture,并且您可以将InAppNotification 放在MainPage 中,当您需要显示InAppNotification 时,您需要使用MessagingCenter 从其他页面向MainPage 发送事件。

    【讨论】:

    • 我用的是第二种方法,放在ShellPage.xaml中。
    猜你喜欢
    • 2015-03-31
    • 2015-05-06
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多