本示例必须在prism5.0版本以上

PopupWindowAction如何使用MetroWindow?

 

public class Window1ViewModel:BindableBase,IInteractionRequestAware
{
#region Properties
private string str; public string Str
{
get { return str; }
set { SetProperty(ref str, value); }
} #endregion /// <summary>
/// Cancel
/// </summary>
private DelegateCommand<Window> clickCommand; public DelegateCommand<Window> ClickCommand
{
get
{
if (clickCommand == null)
clickCommand = new DelegateCommand<Window>(Click);
return clickCommand;
}
} private INotification notification; public INotification Notification
{
get { return notification; }
set { SetProperty(ref notification,value); }
} public Action FinishInteraction { get; set; } private void Click(Window window)
{
var _notification = (Window1DialogModel)Notification;
_notification.Str = this.str;
_notification.Confirmed = true;
FinishInteraction?.Invoke();
}
}

Window1ViewModel

  public class Window1DialogModel : IConfirmation
{
public string Str { get; set; } //Interface Content
public bool Confirmed { get ; set ; }
public string Title { get ; set ; }
public object Content { get; set; }
}

Window1DialogModel

<UserControl x:Class="Pfu.ScanSnap.Home.UI.SshUIUserData.Views.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:MetroControls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:prism="http://www.codeplex.com/prism"
xmlns:prop="clr-namespace:Pfu.ScanSnap.Home.UI.SshUIUserData.Properties"
xmlns:util ="clr-namespace:Pfu.ScanSnap.Home.UI.SshUIUserData.Util"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
BorderBrush="#FF666666"
BorderThickness="1"
Width="500" Height="300">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/SshUIUserData;component/Styles/ResourceDictionary.xaml"/>
<ResourceDictionary Source="/SshUIUserData;component/Styles/BaseStyles.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Buttons.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources> <Grid>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<TextBox Text="{Binding Str}"/>
<Button Content="Click" Command="{Binding ClickCommand}" CommandParameter="{Binding ElementName=_window1_}"/>
</StackPanel>
</Grid>
</UserControl>

Window1

// 核心块

 public class MetroPopupWindowAction:PopupWindowAction
{
protected override Window CreateWindow()
{
return new MessageDialogWindow();
}
}

MetroPopupWindowAction

<!--Window1 Dialog-->
<prism:InteractionRequestTrigger SourceObject="{Binding Window1DialogRequest}">
<util:MetroPopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
<util:MetroPopupWindowAction.WindowContent>
<local:Window1/>
</util:MetroPopupWindowAction.WindowContent>
</util:MetroPopupWindowAction>
</prism:InteractionRequestTrigger>
private void OK()
{
Window1DialogRequest.Raise(new Window1DialogModel { Str = $"", Title = "Window1" }, _ =>
{
MessageBox.Show(_.Str);
});
}
#endregion #region NotificationRequest
public InteractionRequest<Window1DialogModel> Window1DialogRequest { get; set; }
#endregion public ExportMainWindowViewModel()
{
Window1DialogRequest = new InteractionRequest<Window1DialogModel>();
}

TestWindowViewModel

WPF PrismDialog PopupWindowAction使用MetroWindow的更多相关文章

  1. WPF 自定义Metro Style窗体

    为了使WPF程序在不同版本的操作系统上保持一致的显示效果,我们需要重写WPF控件样式.这篇博客将展示如何创建一个Metro Style的WPF窗体. 首先先看一下最终窗体的效果图, 通过截图我们可以看 ...

  2. WPF 皮肤之MathApps.Metro UI库

    在WPF中要想使用Metro风格是很简单的,可以自己画嘛.. 但是为了节省时间,哈,今天给大家推荐一款国外Metro风格的控件库. 本文只起到抛砖引玉的作用,有兴趣还是推荐大家上官网,Thanks,官 ...

  3. WPF数据爬取小工具-某宝推广位批量生成,及订单爬取 记:接单最痛一次的感悟

    项目由来:上月闲来无事接到接到一个单子,自动登录 X宝平台,然后重定向到指定页面批量生成推广位信息:与此同时自动定时同步订单数据到需求提供方的Java服务. 当然期间遇到一个小小的问题就是界面样式的问 ...

  4. 定时任务 Wpf.Quartz.Demo.2

    定时任务 Wpf.Quartz.Demo.1已经能运行了,本节开始用wpf搭界面. 准备工作: 1.界面选择MahApp.Metro 在App.xaml添加资源 <Application.Res ...

  5. 项目笔记---WPF之Metro风格UI

    写在前面 作为新年开篇的文章,当然要选择比较“Cool”的东西来分享,这自然落到了WPF身上,WPF技术自身可塑性非常强,其强大的绘图技术以及XAML技术比WinForm而言有本质的飞跃. 切入正题, ...

  6. WPF 使用MahApps.Metro UI库

    在WPF中要想使用Metro风格是很简单的,可以自己画嘛.. 但是为了节省时间,哈,今天给大家推荐一款国外Metro风格的控件库. 本文只起到抛砖引玉的作用,有兴趣还是推荐大家上官网,Thanks,官 ...

  7. WPF Prism MVVM 中 弹出新窗体. 放入用户控件

    原文:WPF Prism MVVM 中 弹出新窗体. 放入用户控件 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_37214567/artic ...

  8. Prism5.0新内容 What's New in Prism Library 5.0 for WPF(英汉对照版)

    Prism 5.0 includes guidance in several new areas, resulting in new code in the Prism Library for WPF ...

  9. WPF 加载等待动画

    原文:WPF 加载等待动画 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_29844879/article/details/80216587 ...

随机推荐

  1. python读取excel表

    from xlrd import open_workbookimport re #创建一个用于读取sheet的生成器,依次生成每行数据,row_count 用于指定读取多少行, col_count 指 ...

  2. Navicat for MySQL使用

    Navicat for MySQL使用 导出数据库表与结构 新数据库导入

  3. 【Noip模拟 20160929】树林

    题目描述 现在有一片树林,小B很想知道,最少需要多少步能围绕树林走一圈,最后回到起点.他能上下左右走,也能走对角线格子. 土地被分成RR行CC列1≤R≤50,1≤C≤501≤R≤50,1≤C≤50,下 ...

  4. 制造业期刊-ZT

    小虫一名英国博后,前阵发书,认识了很多机械制造领域的伙伴.得知我录用了多篇顶刊后,很多人私聊我求经验. 哎,哪里那么容易.回想过去5年,制造领域的期刊基本都被拒过一圈.当年自己投稿时就发现,制造顶刊的 ...

  5. React Native在window下的环境搭建(一)

    React Native官方开发文档 以下是本人抄录的: 初次接触React Native感觉和React很像,却是有点类似,但不完全是,React Native有自己的组件对象,不过它也自定义的组件 ...

  6. LevelDB源码分析-MemTable

    MemTable(db/memtable.h db/memtable.cc db/skiplist.h) LevelDB中存储在内存中的那部分KV数据都存储在memtable中,而memtable中的 ...

  7. window.location.href 页面不跳转解决

    function login() { var userid = $("#username").val(); var userpwd = $("#pwd").va ...

  8. js 一些兼容检测

    1. IE5.0之前不支持 document.getElementById(),但存在 document.all[] function getElementById(id) { if(document ...

  9. Centos7安装部署Zabbix3.4

    1.关闭selinux和firewall 1.1检测selinux是否关闭 [root@localhost ~]# getenforce  Disabled                       ...

  10. java_20 LinkedList类

    LinkedList类特有的方法 (1)addLast()  将指定元素添加到此列表的结尾. addFirst() 将指定元素添加到此列表的开始. public static void main(St ...