Project Description
Catel is a very feature-complete, but still light-weight MVVM toolkit. A toolkit means that you can choose what features of the toolkit to use. The MVVM toolkit differs itself from other frameworks and toolkits by the simplicity and solves the "nested user
control" problem with dynamic viewmodels for user controls.
It must be said that the features do compliment eachother, thus it is best to take advantage of all that Catel has to offer. Besides MVVM, it also includes user controls and lots of enterprise library classes.
Are you using Catel in your products, have a blog post or demo app? Please let us know!
Table of contents
Not sure which MVVM framework to choose?
Take a look at the
MVVM framework comparison sheet. There is also an
article available why you should choose Catel as your MVVM framework.
Catel is available in the following languages
- English (default language)
- Chinese (simplified)
- Dutch
- French (thanks to Rajiv Mounguengue)
- German
- Italian (thanks to Luigi Bellanca)
- Spanish (thanks to Miguel Tamarit)
- Turkish (thanks to Ibrahim Demirel)
Want to help us translate? Let us know!
Looking for the latest beta?
Either download the latest source and compile it yourself, or try this url:
http://dl.dropbox.com/u/8455721/Catel%20beta.zip
Sponsors
Need help or consultancy?
If you need help, don't hesitate to create a new discussion. If you need more advanced help, we are also
available for consultancy!
Looking for examples?
The examples are located in a separate repository at
http://catelexamples.codeplex.com.
MVVM
The MVVM framework includes the following features that differs this project from other frameworks:
- Communication with other view models via
simple attributes, no messengers needed
- Solves the
nested user controls problem in MVVM, view models are created on the fly when needed based on the datacontext
- UserControl<TViewModel> and DataWindow<TViewModel> that are fully compatible with the MVVM framework and easy to use
Of course, the framework also implements the features you can find in any MVVM framework:
- ViewModelBase with INotifyPropertyChangedSupport
- Command (a.k.a. RelayCommand)
- EventToCommand
- View Model Services
- Design-time data support
Articles and blog posts
There are several article s available about Catel. The articles are posted on The Code Project:
Blog posts:
OR view the 2.0 ones:
OR view the most important older ones:
Example videos
Video of the CameraService for Windows Phone 7 Mango
Click here to view the video.
Video of the sensors simulation for Windows Phone 7 Mango
Click here to view the video.
Video of the example application that is built to show during presentations about Catel
Click here to view the video.
Video of the example application that is built during the 5th article
Click here to view the video.
Example projects
NuGet
NuGet might become the new way to use libraries. Therefore, Catel is also available via
NuGet!
Handle data the way it should
The framework provides a great way of handling data. In .NET, a lot of interfaces are available to support data manipulation, but strangely Microsoft did not provide a really strong base class for data objects. Catel provides a base object that supports
most of the important interfaces for data handling and change notification:
- IDataErrorInfo
- IDataWarningInfo
- INotifyPropertyChanging
- INotifyPropertyChanged
- IEditableObject
- IComparer
public class Person : DataObjectBase<Person>
{
/// <summary>
/// Public empty constructor.
/// </summary>
public Person() { }
/// <summary>
/// Protected constructor for binary serialization, required to clone the object.
/// </summary>
protected Person(SerializationInfo info, StreamingContext context)
: base(info, context) { }
/// <summary>
/// Gets or sets the first name of the person.
/// </summary>
public string FirstName
{
get { return GetValue(FirstNameProperty); }
set { SetValue(FirstNameProperty, value); }
}
/// <summary>
/// Register the FirstName property to the data object with the type and the default value.
/// </summary>
public readonly PropertyData FirstNameProperty = RegisterProperty("FirstName", typeof(string), string.Empty);
}
Serialize your data objects to disk without the hassle of custom serialization
The framework doesn't stop by simply providing a good framework for data objects in memory. If there is a need to persist the data objects, the SavableDataObjects can be used. The SavableDataObject supports the following additional interfaces:
- IClonable
- ISerializable
- IXmlSerializable
The savable data object supports serialization in the following formats:
The only thing required is to use the right base class:
public class Person : SavableDataObjectBase<Person>
{
// Class declaration goes here
}
What needs to be done to save the data? A simple call to one of the Save methods.
Person person = new Person();
person.FirstName = "Geert";
person.Save("MyFile.dob");
And to load, simply call the static Load method.
Person person = Person.Load("MyFile.dob");
Powerful and easy-to-learn MVVM framework
The framework also supports a base class for view models, and WPF window objects that supports the framework out of the box. This way, it is possible to write your first MVVM app in literally 30 minutes. A view model is declared exactly the same way as a
data object, and has some very useful attributes to directly communicate with the models inside the view model.
The view model provides some shortcuts to easily direct the validation and error handling to the model. However, it also provides the complete freedom to handle the validation inside the view model itself so it can be used in any way required!
public class PersonViewModel : ViewModelBase
{
/// <summary>
/// Gets or sets the person, which is the model in our example.
/// </summary>
/// <remarks>
/// This property uses the <see cref="Model"/> attribute to declare a property as a model. When
/// a property is declared as a model, the view model will automatically try to support the
/// <see cref="IEditableObject" /> if supported.
/// </remarks>
[Model]
public Person Person
{
get { return GetValue(PersonProperty); }
set { SetValue(PersonProperty, value); }
}
/// <summary>
/// Register the Person property to the data object with the type.
/// </summary>
public readonly PropertyData PersonProperty = RegisterProperty("Person", typeof(Person));
/// <summary>
/// Gets or sets the first name of the person.
/// </summary>
/// <remarks>
/// This property uses the <see cref="ViewModelToModel" /> attribute to redirect all the validation
/// and values directly to the right model (Person in this case). Since no property for the model is set,
/// the view model will automatically try to set the "FirstName" property on the model "Person".
/// </remarks>
[ViewModelToModel("Person")]
public string FirstName
{
get { return GetValue(FirstNameProperty); }
set { SetValue(FirstNameProperty, value); }
}
/// <summary>
/// Register the FirstName property to the data object with the type and the default value.
/// </summary>
public readonly PropertyData FirstNameProperty = RegisterProperty("FirstName", typeof(string), string.Empty);
}