首页 > 解决方案 > UWP:如何将视图传递给 InAppNotifications 控件?

问题描述

我正在使用 Windows Community Sample Toolkit 中的 InAppNotifications 控件。我有一个名为 "DemoFile.xaml" 的单独用户控件。这个 Demo 文件有我想在 InAppNotification 控件中显示的内容。

演示文件.xaml

<UserControl>
    <TextBox Text = "Text"/>
  </UserControl>

我的 InAppNotifications 控件看起来像这样

通知.xaml

<UserControl>
   <Grid>
      <tk_ctl:InAppNotification
        x:Name="Notification"
        ShowDismissButton="True"
        StackMode="Replace"/>
</Grid>

此 Notifications.xaml.cs 背后的代码

public class Notifications : UserControl
{
   this.Notification.Show();  // want to pass the Demo File here 
}

如何将演示文件作为参数传递给 Show?

标签: xamluwp-xaml

解决方案


InAppNotification支持使用 UIElement 作为通知内容来显示通知。你可以像下面这样写。

private void Button_Click(object sender, RoutedEventArgs e)
        { 
            var usercontrol = new DemoFile ();
Notification.Show(usercontrol);
        }

推荐阅读