本示例必须在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. 下载安装 STS(Spring Tool Suite),推荐对应 Eclipse 版本号,适用于Windows32位(xp、2003)

    sts下载地址:https://spring.io/tools/sts/legacy 虽然sts内置了版本对应的eclipse,仍推荐使用当前环境下稳定使用的eclipse版本. Start 找到ec ...

  2. TCC细读 - 2 核心实现

    TCC,基于业务层面的事物定义,粒度完全由业务自己控制,本质上还是补偿的思路,它把事物运行过程分为try-confirm-cancel阶段,每个阶段逻辑由业务代码控制 业务活动管理器控制业务活动的一致 ...

  3. Controller层aop

    利用@Around通知修改Controller的返回值 自定义一个注解@OperationBtn 在切入点Controller上加上自定义注解 接下来就是重点了,AspectJ写切面类,对该Contr ...

  4. 最新ceph集群常用命令梳理

    结合网络.官网.手动查询等多方渠道,整理ceph维护管理常用命令,并且梳理常规命令在使用过程中的逻辑顺序.另外整理期间发现ceph 集群的命令体系有点乱,详细情况各自体验. 一:ceph集群启动.重启 ...

  5. springcloud流程图

    自己画的: 别人画的 别人画的2

  6. 将python、pip 加入环境变量

    加python: CMD里输:    path=%path%;C:\Python27 其中   C:\Python27  为python的exe所在的文件夹 加pip: CMD里输:    path= ...

  7. android studio 创建图标

    参考 https://www.cnblogs.com/c546170667/p/5975550.html File-New-Image Asset

  8. 微信小程序和微信公众号的id是一个吗

    首先,简单说下我遇到的问题是我们的程序调用微信小程序得到openid,然后通过openID得到用户的唯一标识,用户得以登录,然而,当我们调用微信公众号也同样的到openid,同一以用户两个不同的ope ...

  9. AngularJS学习笔记(一)

    一.基本指令 1.ng-app=" " 指令初始化一个 AngularJS 应用程序,定义angularJS的使用范围; tips:一个页面里创建多个 ng-app 手动加载即可: ...

  10. C++ 获取字符串中的所有汉字

    #include<iostream> using namespace std; int main() {    char str[20] = "cd大家好df";   ...