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 ...
随机推荐
- python 正则表达式 RE模块汇总记录
re.compile(pattern, flags=0) re.search(pattern, string, flags=0) re.match(pattern, string, flags=0) ...
- 将LinkedHashMap转换为需要的对象
项目中,在获取json数据转换为list类型以后,本来以为可以直接使用,结果在使用中报错“java.lang.ClassCastException: java.util.LinkedHashMap c ...
- [Shell]Bash变量:数值运算及运算符
------------------------------------------------------------------------------------------------- Sh ...
- 关于EXCEPT和INTERSECT的用法和例子
EXCEPT是指在第一个集合中存在,但是不存在于第二个集合中的数据. INTERSECT是指在两个集合中都存在的数据. select qq from #table1 如下: select qq fro ...
- [剑指Offer]5-替换空格
链接 https://www.nowcoder.com/practice/9023a0c988684a53960365b889ceaf5e?tpId=13&tqId=11210&tPa ...
- [leetcode]53. Maximum Subarray最大子数组和
Given an integer array nums, find the contiguous subarray (containing at least one number) which has ...
- 解决 ora-28001 密码过期的处理办法
转载自:https://blog.csdn.net/pengyouchuan/article/details/12905623 操作步骤: $sqlplus / as sysdba ALTER PRO ...
- journalctl 清理journal日志
在CentOS 7开始使用的systemd使用了journal日志,这个日志的管理方式和以往使用syslog的方式不同,可以通过管理工具维护. 使用df -h检查磁盘文件,可以看到/run目录下有日志 ...
- spring入门——applicationContext与BeanFactory的区别
我们知道从applicationContext容器对象中如何获取Bean了,其实spring框架还有另外一种获取bean的方法:BeanFactory代码如下: BeanFactory factory ...
- c++11 线程池学习笔记 (一) 任务队列
学习内容来自一下地址 http://www.cnblogs.com/qicosmos/p/4772486.html github https://github.com/qicosmos/cosmos ...