随笔分类 -  WPF Caliburn

摘要:我们来实现一个最简单的实例HelloCaliburn。首先我们要引入下面几个.dllCaliburn.Core.dll Caliburn.Castle.dllCastle.MicroKernel.dllCaliburn.PresentationFramework.dll Microsoft.Practices.ServiceLocation.dll Castle.Windsor.dll 为了更好的了解Caliburn如何关联View和Presenter(业务逻辑层相当于ViewModel)。我们用了MVVM模式。如下图:配置Caliburn容器在App.xaml中,我们要修改框架名称代码< 阅读全文
posted @ 2011-03-29 10:22 Lee's Blog 阅读(2468) 评论(3) 推荐(1) 编辑
摘要:前面我们触发事件的行为用的是普通的EventMessageTrigger 。其实在Caliburn中有三种事件触发模式:EventMessageTrigger GestureMessageTrigger AttachedEventMessageTrigger 1.EventMessageTrigger 简写:cal:Message.Attach="Divide(left.Text, right.Text) : DivideResult.Text"详细:<cal:Message.Triggers> <cal:RoutedMessageTriggerColle 阅读全文
posted @ 2011-03-18 08:35 Lee's Blog 阅读(1918) 评论(0) 推荐(0) 编辑
摘要:CaliburnApplication配置一:在前面,我们配置Caliburn容器时,是在App.xaml.cs中加了下面段代码:CaliburnFramework .ConfigureCore() .WithPresentationFramework() .Start();配置二:还有一种配置,使用Caliburn基类来配置,要修改的地方有App.xaml.cs和App.xamlpublic partial class App : CaliburnApplication{ public App() { InitializeComponent(); }}<cal:CaliburnAppl 阅读全文
posted @ 2011-03-18 08:34 Lee's Blog 阅读(1210) 评论(2) 推荐(0) 编辑
摘要:首先解决上一篇博客未解决的问题。上次博客中还有一种命令(BoundCommad)没讲到。命令源还是不变的。变得是:我们对命令源封装成属性:命令源ShowMessageCommand:代码public class ShowMessageCommand { [Preview("CanExecute")] public void Execute(string message) { MessageBox.Show(message); } public bool CanExecute(string message) { return !string.IsNullOrEmpty(mes 阅读全文
posted @ 2011-03-15 08:52 Lee's Blog 阅读(1045) 评论(0) 推荐(0) 编辑
摘要:前言:我们知道WPF也有Command,比如自带的复制、粘贴、剪切、撤销等。这里要说的是Caliburn中的Command,它们有什么区别和不同点呢?1、命令源我们首先创建一个ShowMessageCommand.cs类,和ShowTitleMessageCommand.cs类。分别写上相应的命令方法。 [Command] public class ShowMessageCommand { [Preview("CanExecute")] public void Execute(string message) { MessageBox.Show(message); } pub 阅读全文
posted @ 2011-03-10 08:23 Lee's Blog 阅读(2571) 评论(0) 推荐(6) 编辑
摘要:上次的笔记,主要讲的Action。这次讨论下Action的其他两个行为。AsyncActionAsyncAction(异步行为)基于上次的笔记内容,我们在此基础上加一个3秒的时间延迟 [Preview("CanDivide")] public int Divide(int left,int right) { Thread.Sleep(3000); return left / right; } public bool CanDivide(int left,int right) { return right != 0; }当我们输入数字,点button后,这时我们拖动窗体,发现 阅读全文
posted @ 2011-03-09 08:35 Lee's Blog 阅读(2240) 评论(0) 推荐(3) 编辑
摘要:前言:这些内容都是在Caliburn 1.1版本基础上,学习的心得。其中有些不懂的地方或写错的地方请大家指正。基础在配置Caliburn时,我们先要添加3个引用,分别是:Caliburn.Core.dll Caliburn.PresentationFramework.dll Microsoft.Practices.ServiceLocation.dll Caliburn不止这两个引用,要用到的时候,再提出。要想使用Caliburn来写事件,首先要在App.xaml.cs中配置它。打开App.xaml.cs public App() { CaliburnFramework.ConfigureCo 阅读全文
posted @ 2011-03-08 17:20 Lee's Blog 阅读(6179) 评论(3) 推荐(4) 编辑