In this article, I'll show you how to use Caliburn Micro to create embedded message boxes. I will use the default implementation you can obtain in CM's big brother source code, and tweak it a little to have a better look.
Tag - Caliburn Micro
Friday 25 March 2011
[CaliburnMicro] Embedded MessageBox
By Michael DELVA on Friday 25 March 2011, 13:00 - WPF
Monday 21 February 2011
[CaliburnMicro] Dependencies attribute on any depth level of properties
By Michael DELVA on Monday 21 February 2011, 15:00 - C#
I didn't post anything on the blog for a very long time (2010-12-07), so let's break the silence with something new about Caliburn Micro.
In this post, I will briefly show you an update of an "old" article I wrote. The main drawback of the previous version of this dependencies attribute was its inability to make the availability of the action depend on more than one level.
For example, you could write these dependencies, which update the availability of the Do method when either OtherProperty (a property of the same view-model than Do) or OtherProperty.ChildProperty were modified.
[Dependencies("OtherProperty", "OtherProperty.ChildProperty")]
public IEnumerable<IResult> Do()
{
}
With the new Dependencies attribute I'll show you right after the break, you won't be limited to this single level of hierarchy, thus allowing you to write a dependency like:
[Dependencies("OtherProperty.ChildProperty.OneMoreLevelProperty.LastLevelProperty.*")]
public IEnumerable<IResult> Do()
{
}Thursday 18 November 2010
[PostSharp] [Caliburn] Automatic IEventPublisher subscription and publication
By Michael DELVA on Thursday 18 November 2010, 16:00 - C#
If you develop in WPF using the MVVM pattern, you have certainly heard about the Event Aggregator pattern, which allows, as the MSDN says:
decoupling of publishers and subscribers so they can evolve independently.
There are several implementations of this pattern:
Of course, as the title of this article told you, we are going to use the latter, and I will propose an implementation of a PostSharp aspect which will help us to subscribe to events, publish them, and dispose the subscriptions when the view-model is deactivated.
Monday 4 October 2010
[Caliburn Micro] Action filters - Dependencies on "properties of properties", using the Reactive Extensions
By Michael DELVA on Monday 4 October 2010, 17:00 - C#
By default, Caliburn Micro (CM) doesn't contain the action filters which belong to Caliburn (C). There is a recipe on how to implement them back in CM, but unfortunately it doesn't cover all the initial functionalities which are in C.
One feature missing, and that I needed, is the possibility to depend on "properties of properties".
With the recipe, you can add a dependency between the property of a view-model (VM) and another property of this same VM. Thus, when the latter property is changed, the PropertyChanged event of the VM is fired, resulting in the update of the availability of the action on which the Dependencies attribute is put. But what it doesn't allow you to do, is to define something like:
[Dependencies("OtherProperty.ChildProperty")]
This would update the availability of the action if OtherProperty implements INotifyPropertyChanged and if the ChildProperty is modified. You could even use something like:
[Dependencies("OtherProperty.*")]
which would update the availability if any of the properties of OtherProperty is modified.
But let me show you how I implemented this feature on top of the recipe, with the great use of the Reactive Extensions.
Thursday 30 September 2010
[Caliburn Micro] How to use the same view for multiple view-models
By Michael DELVA on Thursday 30 September 2010, 16:32 - C#
The default behavior of Caliburn Micro (CM), when it must locate a view from a view-model, is very straightforward: it takes the full name of the view-model, replaces the word "Model" by an empty string, and locates a view with this new name.
One problem with this way is that you must exactly have one view per view-model. So, if you have an abstract view-model, with multiple derived view-models, which only set some filters on the displayed data, you must have one view per derived VM. Which is kind of annoying, useless, and error prone.
In this short article, I'll show you how to easily implement a new feature which will allow us to specify, with an attribute on top of the VM, the view we want CM to display when we activate the VM.