【问题标题】:UWP: How to pass a view to the InAppNotifications control?UWP:如何将视图传递给 InAppNotifications 控件?
【发布时间】:2021-03-29 10:40:12
【问题描述】:

我正在使用 Windows 社区示例工具包中的 InAppNotifications 控件。我有一个名为 "DemoFile.xaml" 的单独用户控件。这个 Demo 文件有我想在 InAppNotification 控件中显示的内容。

DemoFile.xaml

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

我的 InAppNotifications 控件如下所示

Notifications.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?

【问题讨论】:

    标签: xaml uwp-xaml


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-27
      • 2017-08-08
      • 2019-12-28
      • 1970-01-01
      相关资源
      最近更新 更多