C# Disciples

my life in Avalon ….

[MVVM + Mediator + ACB = cool WPF App] – Intro

Finally I managed to spare some time and build a WPF sample application to showcase the use of MVVM + Mediator and also how AttachedCommandBehaviours can be used to further reduce (or better eliminate) C# code in XAML code behind files. I am also using one of my favorite WPF libraries FluidKit. In the app I create my own 3D transition for the FluidKit TransitionPresenter (I will be posting a whole post on this).

I will be posting at least 4 posts

- MVVM

- MVVM and the Mediator pattern

- FluidKit CoverFlow and FluidKit TransitionPresenter

- Using AttachedCommandBehaviours

Here are some teaser screenshots of the application in action :)

Screen1 Screen2

Screen3 Screen4

 

Setup of application environment

This application uses a SQL Database so you will need an instance of SqlServer 2005 running (you can use SqlServer Express).

I packaged the database as a backup so all you need to do is restore the database from the SqlServer Management Studio Express (this is your easiest option). If you don’t have this I suggest you download it, it’s free.

To restore the database file (WPFDisciplesDB.bak) follow these steps

- First of all download the database file from here.

- Right click on the Databases folder in the SQL Server Management Studio Express and select Restore database

Step 1

This will open a dialog for you. In the Restore Database dialog enter a name for the database in the “To database” text field > Select “From device” radio button and browse for the WPFDisciples.bak that you downloaded. The file will appear in the list. Tick the checkbox (which is un checked by default) and press ok.

Step 2 

Now that we have our database set up all we need to do is specify in the app.config the connection string of the new database and we are done.

Stayed tuned because this should be real fun :)

aaaa I nearly forgot… The data in the database is not the full version… I will add more projects from the mighty WPF Disciples as time goes by…. Will continue updating the download link here (and put a comment or something to show you that I updated the db version)

Download Full Source Code from HERE

Just in case you missed it, here is a copy of the database

About these ads

April 2, 2009 - Posted by | .Net 3.5, mvvm, tips and tricks, WPF, wpf disciples

5 Comments »

  1. A promising start. I look forward to seeing how this series pans out.

    Comment by peteohanlon | April 3, 2009 | Reply

  2. Looks very cool, I am going to mess with it all later. Its really nice to see some cool design from you, its fun isnt it. Code + design= fun

    Comment by sacha | April 3, 2009 | Reply

  3. Looks good. But posible it is a bug in the CommandBehavior and CommandBehaviorBinding

    CommandBehavior.OnEventChanging:
    private static void OnEventChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
    CommandBehaviorBinding binding = FetchOrCreateBinding(d);
    //check if the Event is set. If yes we need to rebind the Command to the new event and unregister the old one
    if (binding.Event != null && binding.Owner != null)
    binding.Dispose();
    //bind the new event to the command
    binding.BindEvent(d, e.NewValue.ToString());
    }
    What happens if we set an event two or more times. Nothings good if we look at CommandBehaviorBinding. The Dispose method check disposed field, and if it true nothings happen.

    Comment by gore01 | April 3, 2009 | Reply

  4. This is very exciting. I can’t wait to see where you take this series…

    Comment by Josh Smith | April 3, 2009 | Reply

  5. [...] DOWNLOAD SAMPLE APP HERE Possibly related posts: (automatically generated)Calling Managed Code from a DLL Created in Visual C++ 2008 [...]

    Pingback by [MVVM + Mediator + ACB = cool WPF App] – The MVVM « C# Disciples | April 14, 2009 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 845 other followers

%d bloggers like this: