Onyx – Part 1
May 7th, 2009
After playing with Prism I have decided the next thing to look at is Onyx. This is a MVVM framework for WPF written by Bill Kempf. The best tutorial I have found on it so far is by Sacha Barber on CodeProject (WPF:FlipTile 3D) and these notes are based on my interpretation of his code.
The View-ViewModel interaction is setup declaratively in the XAML for the view as illustrated below:
<window title="TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
width="300"
height="300"
xmlns:local="clr-namespace:OnyxApp"
xmlns:onyx="http://schemas.onyx.com/2009/fx/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:class="OnyxApp.TestWindow"
onyx:view.model="{x:Type local:TestWindowViewModel}">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
width="300"
height="300"
xmlns:local="clr-namespace:OnyxApp"
xmlns:onyx="http://schemas.onyx.com/2009/fx/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:class="OnyxApp.TestWindow"
onyx:view.model="{x:Type local:TestWindowViewModel}">
The TestWindowViewModel class here is coded as below
namespace OnyxApp
{
public class TestWindowViewModel:ViewModel
{
public TestWindowViewModel(View view):
base(view)
{}
{
public class TestWindowViewModel:ViewModel
{
public TestWindowViewModel(View view):
base(view)
{}
As far as I can see, this is the minimum amount of code to get the MVVM interaction going.