Click here to Skip to main content
Click here to Skip to main content

Convert a Silverlight Navigation Application to use MVVM using Cinch V2

By , 8 Sep 2010
 

Introduction

Although Sacha Barber had been great at explaining in detail how Cinch works in his various articles (Search for Cinch articles here on CodeProject), there has been very little coverage of Cinch for line of business (LOB) applications using Silverlight. Most, if not all, LOB applications require some form of navigation between pages, and as the Silverlight team has created some project templates for navigation, I thought it would be useful to show one way of converting a navigation project to use the MVVM pattern. In particular, we are using Cinch V2, although it would be very easy to tweak this to work with other frameworks such as MVVM Light.

Background

As I said, most, if not all, LOB applications in Silverlight require some sort of navigation between pages (Views). So let’s see how easy it is to use Cinch V2 to convert a navigation project to use MVVM for its main page and navigation framework. Something I certainly struggled with at first and had to leave, and come back to once I was more familiar with Cinch and MVVM.

For documentation on Cinch, start with Sacha Barber's posts on how to use the framework.

I won't go into why you should be using the MVVM pattern, as there are countless articles both here on CodeProject and elsewhere on the web. So if you are not interested in MVVM, stop reading right here.

I looked at various MVVM frameworks, but decided on Cinch because Sacha documents all aspects of his framework so well, it uses MEF, has the ability to show design time data as well as at runtime, and uses a view first approach. Plus, it also has the added bonus of working with WPF as well.

So what’s so important about MEF? Well, for a start, go and read the following 10 Reasons to use the Managed Extensibility Framework, then go to Marlon Crech's site and read up about MEFedMVVM (which drives the MEF parts in Cinch). I think you will then see the great benefits this brings to building large-scale Silverlight applications.

Getting Started

First, go off to the CodePlex site and download the source for Cinch V2 and build the solution to get the two DLLs you will need: Cinch.SL.dll and MEFedMVVM.SL.dll.

Now in Visual Studio 2010, take the following steps:

  • Create a new Silverlight Navigation Application using the navigation project template
  • Add these four folders to the application:
    • Controls
    • Libs
    • Models
    • ViewModels

    As shown below:

    New folders

    Add the two DLLs mentioned above to the libs folder in Windows Explorer, and then add references to them and the following DLLs using the Add References dialog:

    • Cinch.SL
    • MEFedMVVM.SL
    • System.ComponentModel.Composition
    • System.ComponentModel.Composition.Initialization

    The references section of your Silverlight application in the Solution Explorer should now look like the image below.

    New References

    Now open up App.xaml.cs and add these using clauses, then change the Application_Startup method as below, leaving the Application_UnhandledException method in its original state.

    using Cinch;
    using System.ComponentModel.Composition;
    using System.Reflection;
    
    namespace CinchNavigation
    {
        public partial class App : Application
        {
            public App()
            {
                this.Startup += this.Application_Startup;
                this.UnhandledException += this.Application_UnhandledException;
                InitializeComponent();
            }
    
            private void Application_Startup(object sender, StartupEventArgs e)
            {
                CinchBootStrapper.Initialise(new List<Assembly> { typeof(App).Assembly });
                this.RootVisual = new MainPage();
            }

The start of App.xaml.cs should now look like:

App.xaml.cs

So what is happening in the code above? Well, the CinchBootStrapper boots up the Cinch system, and we pass in a list of Assemblies for MEF to find the Exports and Imports to marry up. More on this later. In this case, we are passing in the current assembly (XAP) file. But we could extend this list to include other XAP files, if for instance we were dynamically downloading extra XAP files. See the Cinch documentation for how to do this.

Compile and run the application to check there are no errors. (You won't see anything different yet.)

So what do we need to do to convert the application to use MVVM?

  • Create ViewModels for the Main, Home, and About pages, and link them to the relevant pages (Views in MVVM speak).
  • In the MainPageViewModel, create a method we can hook up to the Navigated event on the Navigation Frame in the MainPage.
  • In the MainPageViewModel, create a method we can hook up to the NavigationFailed event on the Navigation Frame in the MainPage.
  • In the Navigated method, update the hyperlink buttons so they change state to either the 'ActiveLink' or 'InactiveLink' states.

The first three items are not a problem, as we can use the Cinch EventToCommandTrigger behaviour to bind to our events in XAML. But the last item is the main stumbling block, as in good MVVM style (no tight coupling), we should not have any links to the View (Page), and as it stands, we would need to access the View to set the Hyperlinks state property after navigation has taken place. So what is the answer?

The Solution

Well, we need a way of dynamically creating a list of hyperlinks, but with an extra property of CurrentState. We then need to bind values to the Hyperlink properties of Uri, Content, CurrentState from our ViewModel. We will also need to create a separator between the Hyperlinks, and show this for all links except the first in the list.

My way of achieving this goal was as follows:

  • Extend the Hyperlink class by creating a new control called MvvmHyperlink which extends the Hyperlink control by adding a new dependency property of CurrentState.
  • Create a class (NavItemInfo) for the properties we will bind to our MvvmHyperlink controls.
  • Replace the list of hyperlinks in the XAML of the main page with an ItemsControl and data template to hold our new controls.
  • In the constructor of the MainPageViewModel, create an observable collection of our new NavItemInfo items and bind these to the ItemsControl.
  • Wire up the Navigated and NavigationFailed events to Commands in the ViewModel.
  • Finally, delete the event handlers in the MainPage code-behind file.

Let’s start with the new Hyperlink control. Add a new class file to the Controls folder called MvvmHyperlink. Then add the following code to it:

public class MvvmHyperlink : HyperlinkButton
{
    public static readonly DependencyProperty CurrentStateProperty =
        DependencyProperty.Register("CurrentState", typeof(object),
        typeof(MvvmHyperlink),
        new PropertyMetadata(CurrentStatePropertyChanged));

    public object CurrentState
    {
        get { return (object)GetValue(CurrentStateProperty); }
        set { SetValue(CurrentStateProperty, value); }
    }

    private static void CurrentStatePropertyChanged(DependencyObject o, 
                        DependencyPropertyChangedEventArgs e)
    {
        MvvmHyperlink hyp = o as MvvmHyperlink;
        if (hyp != null)
        {
            hyp.OnCurrentStatePropertyChanged((object)e.NewValue);
            VisualStateManager.GoToState(hyp,(string)e.NewValue, true);
        }
    }

    private void OnCurrentStatePropertyChanged(object newValue)
    {
        CurrentState = newValue;
    }
}

This is not really the place to go into the details of dependency properties, and I will leave it up to the reader to research it themselves. But it will create our CurrentState property that we can bind to.

Next, we need our new NavItemInfo class. So under the Models folder, create a new class called NavItemInfo. Then add the following code:

using Cinch;

namespace CinchNavigation.Models
{
    public class NavItemInfo : ViewModelBase
    {
        public bool SeperatorVisible { get; set; }
        public string PageUri { get; set; }
        public string ButtonContent { get; set; }
        public string CurrentState { get;  set; }
       
    }
}

Now we need to start work on our MainPage XAML. First off, add some references at the top of the XAML:

xmlns:controls="clr-namespace:CinchNavigation.Controls"
xmlns:CinchV2="clr-namespace:Cinch;assembly=Cinch.SL"
xmlns:meffed="http:\\www.codeplex.com\MEFedMVVM"
meffed:ViewModelLocator.ViewModel="MainPageViewModel"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

So what is happening here? Well, first we have a reference to our Controls folder. Then the following two references are for Cinch and MEF. Then, the MEFfed line hooks up our Page (View) with our ViewModel. Finally, we reference the Interactivity DLL for our behaviours that will link events to commands.

Now we need to alter the navigation frame XAML to add our behaviours for the Navigated and NaviagationFailed event handlers, using the Cinch built-in behaviour for hooking up UI events to commands in our ViewModel.

<navigation:Frame x:Name="ContentFrame"
                    Style="{StaticResource ContentFrameStyle}"
                    Source="/Home">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Navigated">
            <CinchV2:EventToCommandTrigger Command="{Binding Navigated}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="NavigationFailed">
            <CinchV2:EventToCommandTrigger Command="{Binding NavigationFailed}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <navigation:Frame.UriMapper>
        <uriMapper:UriMapper>
            <uriMapper:UriMapping Uri=""
                                    MappedUri="/Views/Home.xaml" />
            <uriMapper:UriMapping Uri="/{pageName}"
                                    MappedUri="/Views/{pageName}.xaml" />
        </uriMapper:UriMapper>
    </navigation:Frame.UriMapper>
</navigation:Frame>

Now we need to alter the links area to have an ItemsControl, with a template to display our Hyperlink control and bind it to our list of links, which will be built in our ViewModel.

<Border x:Name="LinksBorder"
        Style="{StaticResource LinksBorderStyle}">
    <StackPanel x:Name="LinksStackPanel"
                Style="{StaticResource LinksStackPanelStyle}">

        <ItemsControl x:Name="NavItems"
                        ItemsSource="{Binding Path=NavItemsInfo}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel  Name="LayoutRoot"
                                    Orientation="Horizontal">
                        <Rectangle Name="separator"
                                    Style="{StaticResource DividerStyle}"
                                    Visibility="{Binding SeperatorVisible}" />
                        <controls:MvvmHyperlink x:Name="hlink"
                                                Style="{StaticResource LinkStyle}"
                                                NavigateUri="{Binding PageUri}"
                                                TargetName="ContentFrame"
                                                Content="{Binding ButtonContent}"
                                                CurrentState="{Binding CurrentState}" />
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </StackPanel>
</Border>

Now we are ready to code our MainPageViewModel. First we need some using clauses.

using System.ComponentModel.Composition;
using System.Windows.Navigation;
using Cinch;
using MEFedMVVM.ViewModelLocator;
using System.Collections.ObjectModel;
using CinchNavigation.Models;

Next we need to mark up our class with some attributes that Cinch using MEFedMVVM needs to marry our view (MainPage) with our ViewModel (MainPageViewModel).

[ExportViewModel("MainPageViewModel")]
[PartCreationPolicy(CreationPolicy.Shared)]
public class MainPageViewModel : ViewModelBase

ExportViewModel will allow MEF to load this into memory, and the PartCreation of Shared will create a singleton. NonShared will create a new instance on every call. But as we want only one instance for our main page, Shared is ideal. Finally, we inherit our class from ViewModelBase, a Cinch ViewModel base class. Then we need some public properties.

public SimpleCommand<Object, EventToCommandArgs> Navigated { get; private set; }
public SimpleCommand<Object, EventToCommandArgs> NavigationFailed { get; private set; }
public ObservableCollection<NavItemInfo> NavItemsInfo { get; private set; }

First, our commands that will be fired by our behaviours, and finally our collection of NavItemInfo items. Now in our constructor, we will setup our links, and create our commands.

public MainPageViewModel()
{
  NavItemsInfo = new ObservableCollection<NavItemInfo>();
  NavItemsInfo.Add(new NavItemInfo { ButtonContent = "home", 
                   PageUri = "/Home", SeperatorVisible = false, 
                   CurrentState = "ActiveLink" });
  NavItemsInfo.Add(new NavItemInfo { ButtonContent = "about", 
                   PageUri = "/About", SeperatorVisible = true, 
                   CurrentState = "InActiveLink" });
  //add any more pages here, note: seperator is only hidden on the first link

  // Setup the commands
  Navigated = new SimpleCommand<Object, EventToCommandArgs>(ExecuteNavigatedCommand);
  NavigationFailed = new SimpleCommand<Object, 
                     EventToCommandArgs>(ExecuteNavigationFailedCommand);
}

As you can see, we have setup two links here: Home and About, and set their initial states. Then we go on to create the new commands and hook these up to two private methods. The code for these two are:

private void ExecuteNavigatedCommand(EventToCommandArgs args)
{
    NavigationEventArgs navArgs = (NavigationEventArgs)args.EventArgs;
    foreach (var link in NavItemsInfo)
    {
        if (link.PageUri.ToString().Equals(navArgs.Uri.ToString()))
        {
            link.CurrentState = "ActiveLink";
        }
        else
        {
            link.CurrentState = "InActiveLink";
        }
    }
}

private void ExecuteNavigationFailedCommand(EventToCommandArgs args)
{
    NavigationFailedEventArgs navArgs = (NavigationFailedEventArgs)args.EventArgs;
    navArgs.Handled = true;
    ChildWindow errorWin = new ErrorWindow(navArgs.Uri);
    errorWin.Show();
    // note: we could use the Cinch IChildWindowService for the error window
}

Taking these one at a time. ExecuteNavigatedCommand takes an EventToCommandArgs parameter which contains the EventArgs, which in this case is NavigationEventArgs, one of the properties of which is the URI of the page that has been navigated to. With this, we can loop through the NavitemsInfo list and update the state. Now, because we are using an ObservableCollection which implements NotifyPropertyChanged, our UI will be updated! ExecuteNavigationFailedCommand gets a NavigationFailedEventArgs object back, which again has a URI, this time of the page that failed. From this, we have replicated the existing code.

Now you can finally delete or comment out the event handlers in the code-behind file of MainPage. Providing you have not made any typos, your program should now run.

Finally

The source project has also wired up ViewModels for both the Home and About pages. These follow the same pattern as we have used with the MainPage, so I will leave it as an exercise for the reader to implement this themselves, or grab the source! Plus, it also includes a very basic test project, just to show you how to get started unit testing with MVVM. Suggestions for improvements would be very welcome; or if you feel my approach is completely wrong and there is a much better approach, please let me know.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

BenWintringham
Software Developer Ben Wintringham Software
United Kingdom United Kingdom
Member
I am a UK based developer who works mainly on web projects using C#, ASP.Net (webforms and MVC) and my latest love Silverlight.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questiongood article to help me.memberlandzhang26 Jan '12 - 10:31 
Thanks.
BugCurrent link not highlighted [modified]memberOasisLiveForever26 Jun '11 - 1:25 
Hi,
 
I read your article and I tried to migrate a default Silverlight 4 navigation application to MVVM pattern.
The only problem I have is that the current link is not highlighted in navigation links.
 
So I added in the MainPage.xaml a MvvmHyperlink control not binded to NavItemsInfo collection.
I also added a button and in its code behind I manually changed the current state of the link: MyLink.CurrentState = "ActiveLink";
 
This works, the link is highlighted, so I think there is a problem when the link is binded to the observable collection NavItemsInfo.
 

Is it a bug or am I doing something wrong?

modified on Monday, June 27, 2011 12:06 AM

GeneralRe: Current link not highlighted [modified]memberMember 786593119 Apr '12 - 16:48 
I found this problem too.
It fails because NavItemInfo.CurrentState set does not raise NotifyPropertyChanged, so the View never notices any change.
 
Perhaps you will also need to force the initial CurrentState setting to be noticed.
If the initial setting is before the View is fully created, no update of the View occurs.
Can be fixed in MvvmHyperlink by forcing the update in OnApplyTemplate.
 
Also when this is fixed the state never reverts back from active to inactive. This is because the inactive state name in SL5 at least is "InactiveLink" not "InActiveLink"
GeneralMy vote of 5memberscott.leckie23 Feb '11 - 2:25 
Excellent work - thanks! Now I need to go play with Cinch.
GeneralNice article but...memberMember 456543318 Dec '10 - 7:47 
...you can do this quite easily using Prism and without the ugliness of MEF as well
GeneralRe: Nice article but...memberBenWintringham18 Dec '10 - 8:47 
Hi
Yes of course you can, but Prism is a big learning curve, and if you have no intention of going cross platform, and do not have a enterprise level app, it's a bit overkill.
I am suprised that you feel MEF is ugly, I find it very concise and simple to use. Plus it makes it very easy to divide up your Silverlight apps into several xap files and load them on demand. Essential for any reasonable sized Silverlight app, to keep down initial loading time.
Ben
GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 6:29 
Disagree, Prism is not a big learning curve, it’s a “correct” learning curve, it's not overkill either.
I use it on “small” applications, separation of concerns, regions management etc.
 
Problem with Cinch is, the lack of a knowledge base (re:- your article is an example), yes it does everything under the MVVM sun but still there is a distinct lack of knowledge out there.
And Sacha seems to of moved on, that’s the problem with individual effort frameworks/APIs, they don’t mature.
 
Just google Cinch v Prism to compare the general knowledge base
 
MEF, yes I suppose it’s a personal preference, and personally I can’t stand decorating class/methods with attributes, ugh !
 
And MEF throws up the argument View first or Model first design (good or bad...with ever).
 
Also, you don’t need MEF to dynamically load XAPs on demand
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 8:11 
I have to say PRISM is a big learning curve. Years after it was released and Karl Shifflett (former MVP and now Microsoft Patterns & Practices man) is now working on labs to get people into PRISM.
 
It is big learning curve.
 
Also I think why more people use PRISM, is an obvious one, is comes from Microsoft and people will ALWAYS trust that, rightly or wrongly.
 
And I have not so much moved on, but rather feel satisfied with my efforts to look at other things. Cinch V2 pretty much does all I wanted from a MVVM framework, I am not a lover of Modules, so will not be doing that, I do like PRISM regions a lot, but I have something similar to that in Cinch for WPF so am happy with that too.
 
At the end of the day I like MVVM and WPF, but there is way more about there to learn, I have a big old list to still look at.
 
Still interesting discussion, thanks for having it.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Re: Nice article but...mvpSacha Barber19 Dec '10 - 8:11 
I have to say PRISM is a big learning curve. Years after it was released and Karl Shifflett (former MVP and now Microsoft Patterns & Practices man) is now working on labs to get people into PRISM.
 
It is big learning curve.
 
Also I think why more people use PRISM, is an obvious one, is comes from Microsoft and people will ALWAYS trust that, rightly or wrongly.
 
And I have not so much moved on, but rather feel satisfied with my efforts to look at other things. Cinch V2 pretty much does all I wanted from a MVVM framework, I am not a lover of Modules, so will not be doing that, I do like PRISM regions a lot, but I have something similar to that in Cinch for WPF so am happy with that too.
 
At the end of the day I like MVVM and WPF, but there is way more about there to learn, I have a big old list to still look at.
 
Still interesting discussion, thanks for having it.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 8:13 
Just one other thing,
Member 4565433 wrote:
And MEF throws up the argument View first or Model first design (good or bad...with ever).

 
Designers like View 1st, as its works in Blend.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 6:26 
I am with Ben on this one, I think MEF is most elegant, and if you are doing large Silverlight app, MEF DeploymentCatalog is a MUST to manage the multiple XAPs. Also you may be surprised that the Microsoft Project Manager (Glenn Block) that helped write/manage PRISM also wrote MEF. And I know for a fact Glenn loves MEF, I have spent many a long night emailing Glenn talking MEF so feel I am able to say this with some certainty.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 6:29 
Also MEF has better metadata support so your queries against the container are better. PRISM uses Unity, so is a standard IOC container, how would you inject 2 instance of a ISomeInterface in PRISM and work out which one to use at design time vs runtime say. Or which one is the V1 one version and which is V2 version. Ok App.Config can help for versions, but this all comes for free with MEF.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 7:28 
Yes, I can see your point about Interfaces, design time Expression v .net runtime.
 
My problem with MEF is the fact it’s attribute orientated. Masses of attributes littered about your code.
 
Prism, nice and sweet injection, parameters of a constructor. Again, personal preference.
 
Also, don’t assume Prism and Unity, write your own bootstrapper and use StructureMaps.
 
Also, doing event aggregation with MEF is more confusing/difficult than Prisms EventAggregator.
As I said it’s down to preference.
 
Btw, I used Cinch v1 on a finance project early this year, I thought it was very good, did what I/we wanted to do.
But unfortunately the project manager did not. And he being the one to be obeyed got his way, so we wrote a lot of the functionality ourselves, e.g. thread factories, window manager factories etc.
 
I haven’t had a chance to play with V2, maybe over the Christmas hols.
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 8:03 
Member 4565433 wrote:
Also, don’t assume Prism and Unity, write your own bootstrapper and use StructureMaps.

 
Cinch V1 started out with Castle, then it was Unity, then I created an interface so you could provide your own IOC container.
 
Also did you mean StructureMap the IOC container? It is nice, for pure IOC love, my favourite is Castle due to the way it wires/installs and intercepts..I like it.
 
Member 4565433 wrote:
Also, doing event aggregation with MEF is more confusing/difficult than Prisms EventAggregator.

 
What do you mean by this, MEF is just a IOC like container, where as PRISM is a framework that contains a Unity container (say) along with other stuff like EventAggregator/Region support/MOdules etc etc.
 
MEF does not have EventAggregator as its just an IOC like container, PRISM obviously has more as its an entire framework, as is Cinch (V1 and V2), so you would expect something like Cinch, or any of the MVVM frameworks to offer something like PRISM EventAggregator, and of course Cinch does, its called the Mediator :
 
WPF : If Carlsberg did MVVM Frameworks Part 2 of n
 

Laurent Buginon has something similar in MVVMLight as well, NRoute, uses the Subject and IObservable/IObserver Reactive stuff (Rx from Microsoft labs) to do same thing. They all do something like EventAggegator, but MEF should NOT do this, it is just doing IOC type stuff, not messaging.
 

Like you say its all down to personal preference, but for my money I like Cinch a lot, and V2 is really really cool I think, but then I would. Nice to hear you used V1 though, have a look at V2 articles, I think V2 is way better.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 8:37 
Yeah, I intend to have a look at V2, over Christmas hols, here in the arctic region of Yorkshire
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 20:30 
Yeah I like it loads better than V1, as I say the only thing I like better in PRISM is regions. But in CinchV2 for WPF I have a new improved workspace idea that can be applied to ListBoxs/Tabs/ContentPresenter. Not quite as flexible as PRISM Region Adaptors but covers about 80-90% of most peoples requirements. After all if you want to show more than 1 item in a list, ListBox, if you want the items wrapped rather than stacked, change ListBox ItemsPanelTemplate, and if you want 1 item using a ContentPresenter.
 
But regions do not enable View 1st (as far as I know) which is a must for designer friendly development. Unless you are willing to use the Expression Blend d: Design time ViewModel approaches / data. I am not, as I think it produces code smell which I do not like.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 8:46 
This is interesting MEF and events
 
http://codebetter.com/glennblock/2009/02/23/event-aggregation-with-mef-with-and-without-eventaggregator/[^]
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 20:35 
Interesting, though it still has dependency on PRISM Dlls for the inherited event type. I mean MEF can import events (you remember the Rx one I did right, well I used MEF to [Import] Rx exported mouse events. In my opinion MEF really is the sh1t man.
 
But as you say its all down to personal preference.
 
Hey if you like IOC Containers, I am just about to release an AOP article which shows you how to do AOP using Castle/Unity/LinFu and also ILWeaving using Cecil.Mono and PostSharp.
 
Should be ready in about 1 week I hope. Then I have a whole series on Task Parrallel Library (going from simple to quite advanced (creating your own Partioner and all), should be fun.
 
So NO!!!! I will not be sticking to WPF (I feel we can joke about that now right? Wink | ;-) )
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 21:49 
Nice one, I look forward to reading them, espicially TPL.
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 21:54 
Soon
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 8:16 
Member 4565433 wrote:
I thought it was very good, did what I/we wanted to do.
But unfortunately the project manager did not.

 
Are you saying you liked it, but your project manager didn't? Would be curious to know what he did not like, all feedback welcome.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 8:35 
He didn't like it because the consultancy were/are a Microsoft shop !
I was (still am) a contractor, contracting to the consultancy, since left....thankfully
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 20:25 
Member 4565433 wrote:
He didn't like it because the consultancy were/are a Microsoft shop !

 
Huh....Don't get what you mean, Cinch was written in .NET which is Microsoft based, or is it that the consultancy did not produce it itself?
 
Either way I like it, and it works.
 
PS: I am sorry we fell out some time ago, you caught me in a moment of intensity, for which I apologize.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 21:51 
Everything had to be Microsoft released/ verified or what ever they said, can't remember their exact wording.
Apart from Infragistic's controls, which we were allowed to use.
 
Bit head in the sand I know, but they paid good Smile | :)
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 21:54 
Member 4565433 wrote:
Apart from Infragistic's controls, which we were allowed to use.

 
HaHaHa......I would pay you not to use those. They are so heavy man
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 22:41 
Yep, I totally agree.
 
It's frustrating working via a consultancy, never again.
Hands tied, well and truely.
GeneralRe: Nice article but...mvpSacha Barber19 Dec '10 - 23:16 
WOW we (us 2) really have come full circle, from vehemently disagreeing (past discussions on different article, where we angered each other), to totally agreeing, good on us. As I say been good to chat, and keep your eyes peeled for the AOP stuff.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralRe: Nice article but...memberMember 456543319 Dec '10 - 23:48 
Yes, I'll read intently, all part of the global knowledge base Smile | :)
 
Take care
GeneralRe: Nice article but...mvpSacha Barber20 Dec '10 - 2:44 
Cheers for now
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

AnswerThanks SachamemberBenWintringham16 Dec '10 - 7:53 
Great framework, works very well in Silverlight.
I did prod Dave at Silverlight cream. But he was unaware of Cinch.
I would suggest you give him a prod as well, as Cinch is not well known for Silverlight and that's a shame.
Regards
Ben
GeneralRe: Thanks SachamvpSacha Barber19 Dec '10 - 6:27 
Funny as I have never heard of "Silverlight cream" either. I am not fussed if it does not become the main stream SL MVVM framework, I would certainly use in preference to MVVMLight for example, as I think it does more. Also NRoute is very nice.
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralDon't know how I missed this, but hey I am going to give it a 5. [modified]mvpSacha Barber16 Dec '10 - 2:03 
But I would I guess. I will add a link to this article from my CInch codeplex site. Thanks for writing it. Good to see someone using the fairly new Cinch for Silverlight. Cool
 
Mentioned them here : http://sachabarber.net/?p=844[^] and here : http://cinch.codeplex.com/
Sacha Barber
  • Microsoft Visual C# MVP 2008-2010
  • Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net
modified on Thursday, December 16, 2010 8:17 AM

GeneralThats great now how to bring RIA entities in Cinch'ed up...memberDrammy29 Oct '10 - 0:20 
Good work Ben, thanks for taking the time to write the article. It has helped me better understand all the technologies involved... I do struggle with this particular learning curve.
 
I am interested in using this approach but also pulling through entity framework objects, preferably using RIA services. Any ideas?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 8 Sep 2010
Article Copyright 2010 by BenWintringham
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid