WPF PrismDialog PopupWindowAction使用MetroWindow
本示例必须在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的更多相关文章
- WPF 自定义Metro Style窗体
为了使WPF程序在不同版本的操作系统上保持一致的显示效果,我们需要重写WPF控件样式.这篇博客将展示如何创建一个Metro Style的WPF窗体. 首先先看一下最终窗体的效果图, 通过截图我们可以看 ...
- WPF 皮肤之MathApps.Metro UI库
在WPF中要想使用Metro风格是很简单的,可以自己画嘛.. 但是为了节省时间,哈,今天给大家推荐一款国外Metro风格的控件库. 本文只起到抛砖引玉的作用,有兴趣还是推荐大家上官网,Thanks,官 ...
- WPF数据爬取小工具-某宝推广位批量生成,及订单爬取 记:接单最痛一次的感悟
项目由来:上月闲来无事接到接到一个单子,自动登录 X宝平台,然后重定向到指定页面批量生成推广位信息:与此同时自动定时同步订单数据到需求提供方的Java服务. 当然期间遇到一个小小的问题就是界面样式的问 ...
- 定时任务 Wpf.Quartz.Demo.2
定时任务 Wpf.Quartz.Demo.1已经能运行了,本节开始用wpf搭界面. 准备工作: 1.界面选择MahApp.Metro 在App.xaml添加资源 <Application.Res ...
- 项目笔记---WPF之Metro风格UI
写在前面 作为新年开篇的文章,当然要选择比较“Cool”的东西来分享,这自然落到了WPF身上,WPF技术自身可塑性非常强,其强大的绘图技术以及XAML技术比WinForm而言有本质的飞跃. 切入正题, ...
- WPF 使用MahApps.Metro UI库
在WPF中要想使用Metro风格是很简单的,可以自己画嘛.. 但是为了节省时间,哈,今天给大家推荐一款国外Metro风格的控件库. 本文只起到抛砖引玉的作用,有兴趣还是推荐大家上官网,Thanks,官 ...
- WPF Prism MVVM 中 弹出新窗体. 放入用户控件
原文:WPF Prism MVVM 中 弹出新窗体. 放入用户控件 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_37214567/artic ...
- 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 ...
- WPF 加载等待动画
原文:WPF 加载等待动画 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_29844879/article/details/80216587 ...
随机推荐
- Oracle,cast函数
cast(要转换的值 AS 转换的类型): 问题:' ' as FSubBillNo 若用此法 oracle 默认字段类型为char型 且字段长度度为输入空格的长度,会导致字符串 ...
- svn的下载及安装
什么是SVN: SVN是Subversion的简称,是一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS. SVN的下载安装: 下载地址:https: ...
- Jquery中的 Deferred分析
参考:https://www.idaima.com/a/1627.html http://www.cnblogs.com/aaronjs/p/3356505.html 未完!
- 关于spfa
关于spfa的一些事宜.... 刚开始学的时候只会跑最短路,代码都是背下来的.以下是背的代码... inline void spfa(int s) { queue<int>q;q.push ...
- 在windows下安装Git并用GitHub同步
准备环境: 1,注册github账户 2,下载安装git(下载地址:https://git-scm.com/download/win) 注释: git是什么? git是版本管理工具,当然也是分布式的管 ...
- Spring学习,初识Spring
Spring概述 将Spring理解为管理对象间依赖关系的容器 “解耦” 根据功能的不同,可以将一个系统中的代码分为 主业务逻辑 与 系统级业务逻辑 两类 ```Spring 是为了解决企业级开发的复 ...
- Linux进程的原理及与信号的联系
第1节 程序.进程.守护进程.僵尸进程的区别 程序.进程.守护进程.僵尸进程: 程序:c/php/java,代码文件,静态的,放在磁盘里的数据. 进程:正在内存中运行的程序,进程是动态的,会申请和使用 ...
- 第一章 C++语言入门
标准数据类型 C++语言提供了丰富的数据类型,如整数类型.实数类型(浮点数).字符类型等.每种数据类型均有均值范围,Dev-C++(4.9.9.2)是Windows平台 ...
- Python项目--Scrapy框架(二)
本文主要是利用scrapy框架爬取果壳问答中热门问答, 精彩问答的相关信息 环境 win8, python3.7, pycharm 正文 1. 创建scrapy项目文件 在cmd命令行中任意目录下执行 ...
- git 添加分支并与远程连接
今天由于项目需要,要改版,为了不影响当前网站,所以用分支来管理 首先,在本地添加分支dev git checkout -b dev 提交远程,让同事拉取这个分支,我是直接push了,推到远程. 同事在 ...