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 ...
随机推荐
- android toolbar效果2
只有一个按钮的情况 <resources> <string name="app_name">照片</string></resources& ...
- 学习C++,应该循序渐进的看哪些书?
在某博客上看到的一个C++书籍阅读清单,可以参考下: 阶段 1<Essential C++>这是一本内容不多但很实用的C++入门书籍,强调快速上手与理解C++编程.本书主要围绕一系列逐渐复 ...
- Spring.Net配置
<?xml version="1.0" encoding="utf-8"?> <configuration> <!--一定 ...
- IntelliJ IDEA——SVN的配置及使用
服务端:VisualSVN-Server-3.9.1-x64 下载地址:https://www.visualsvn.com/server/download/ TortoiseSVN 安装 下载地址:h ...
- 【Django】重定向
view函数中使用重定向方法 return HttpResponseRedirect('redir2.html')的时候不自觉的在前面加了request参数,结果报错: TypeError at /b ...
- HDU 6304 Chiaki Sequence Revisited
题目链接 : http://acm.hdu.edu.cn/showproblem.php?pid=6304 多校contest1 Problem Description Chiaki is int ...
- 347. Top K Frequent Elements 最常用的k个元素
[抄题]: Given a non-empty array of integers, return the k most frequent elements. For example,Given [1 ...
- oracle 导入DMP文件时IMP-00013: 只有 DBA 才能导入由其他 DBA 导出的文件 IMP-00000: 未成功终止导入
参考: https://blog.csdn.net/breaker892902/article/details/11004495 给要导入的用户授权 插入成功
- Vue 的生命周期图
- small_trick_on_IT/PC
1.浏览器下ctrl+F可实现文本查找 其余还有 2.将软件目录放到环境变量Path下,Ctrl+R输入.exe软件名即可调用. (tips:可把常用软件建立快捷方式,统一放在某一目录下噢!)