Skip to content
Antony Male edited this page Apr 29, 2014 · 12 revisions

Stylet is a minimal, but powerful, MVVM framework inspired by Caliburn.Micro. Its intention is to cut down on the complexity and magic even further, to allow people (coworkers) unfamiliar with any MVVM framework to get up to speed more quickly.

A brief feature list is shown below:

A ViewModel-First approach

The classic MVVM structure, where a view knows how to instantiate its ViewModel, and ViewModels typically don't communicate directly, is known as View-first. However, reversing this pattern - instantiating the ViewModels yourself and having the Views automatically attached - provides many advantages, allowing you to compose your ViewModels in a way which should feel very familiar. This ViewModel-first approach is the only one supported by Stylet.

Actions

The ICommand interface which WPF uses is powerful but a bit clunky and unintuitive. It doesn't seem right that actions to be taken by your ViewModel in response to things like button clicks should be represented as properties, rather than methods. A simple <Button Command="{s:Action DoSomething}"/> will cause DoSomething() on your ViewModel to be called every time the button is clicked. Additionally, if you have a bool property called CanDoSomething, that will be observed and used to tell whether the button should be enabled or disabled.

Actions also work with events, allowing you to do things like <Button MouseEnter="{s:Action DoSomethingElse}"/>.

Screens and Conductors

The Event Aggregator

Stylet's Event Aggregator is very similar to Caliburn.Micro's, and allows subscribers to receive messages from publishes without either having knowledge of, or retaining, the other. This is particularly useful for messaging between ViewModels, although it has plenty of other uses.

The WindowManager

With a ViewModel-first approach, you display windows and dialogs by referencing the ViewModel to display, and the View gets attached automatically. The WindowManager allows this to be done with ease.

Clone this wiki locally