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

WPF: If Carlsberg did MVVM Frameworks: Part 6 of n

By , 4 Sep 2009
 

Contents

Cinch Article Series Links

Introduction

Last time we started looking at Unit testing using Cinch. In this article, I will be looking at the following:

Prerequisites

The demo app makes use of:

  • VS2008 SP1
  • .NET 3.5 SP1
  • SQL Server (see README.txt in the MVVM.DataAccess project to learn what you have to setup for the demo app database)

Special Thanks

I guess the only way to do this is to just start, so let's get going, shall we? But before we do that, I just need to repeat the special thanks section, with one addition, Paul Stovell, who I forgot to include last time.

Before I start, I would specifically like to say a massive thanks to the following people, without whom this article and the subsequent series of articles would never have been possible. Basically, what I have done with Cinch is studied most of these guys, seen what's hot, what's not, and come up with Cinch. Which I hope addresses some new ground not covered in other frameworks.

  • Mark Smith (Julmar Technology), for his excellent MVVM Helper Library, which has helped me enormously. Mark I know I asked your permission to use some of your code, which you most kindly gave, but I just wanted to say a massive thanks for your cool ideas, some of which I genuinely had not thought of. I take my hat off to you mate.
  • Josh Smith / Marlon Grech (as an atomic pair) for their excellent Mediator implementation. You boys rock, always a pleasure.
  • Karl Shifflett / Jaime Rodriguez (Microsoft boys) for their excellent MVVM Lob tour, which I attended, well done lads.
  • Bill Kempf, for just being Bill and being a crazy wizard like programmer, who also has a great MVVM framework called Onyx, which I wrote an article about some time ago. Bill always has the answers to tough questions, cheers Bill.
  • Paul Stovell for his excellent delegate validation idea, which Cinch uses for validation of business objects.
  • All of the WPF Disciples, for being the best online group to belong to, IMHO.

Thanks guys/girl, you know who you are.

The Demo App

In some ways, this article will be a bit of a strange one, as I have already covered everything you need to know about how to construct the demo app or any other MVVM based app (of course, using the Cinch framework), so I will not be covering any code in this article as I think that has been pretty much covered by all the previous articles.

What this article shall concentrate on is what the demo app looks like and how it is made up; of course while doing that, I will explain how and why certain Cinch classes/objects are used and why certain design ideas were followed, but if you are expecting a full run through of the code, this article is not the place for that, you should refer to the previous articles for that.

I am hoping that by now you are armed with enough Cinch know-how to dismantle the demo app by yourselves and see what is going on in it. Remember, you have all the Cinch articles prior to this one to help you out.

What It Looks Like

So far I have written five other Cinch articles, and believe it or not, there has not been one screenshot of the demo app, which is largely down to the fact that I have been explaining the framework and how to test with it, whereas this article talks about the look and structure of the demo app, so without further ado, we need to see some screenshots. Let's have a look at some screenshots, shall we:

Start Page

Add/Edit Customer (Add New Mode Shown Below)

Add/Edit Customer (Edit Mode Shown Below 1/2 way Through Editing Customer Order)

Search Customers

How It Is Made

The general idea behind the demo app is quite a simple one. The following function points explain how it should all work:

  1. The UI will be a tabbed interface that shall start out with a start page pre-loaded.
  2. The UI shall support creating a new Customer from both the start page and a menu item. In both cases, a new tab should be opened, unless an Add/Edit Customer tab is already open, which is a stupid limit that I artificially imposed just to show off how to work with Mediator and Workspaces.
  3. The UI shall support searching of Customers from both the start page and a menu item. In both cases, a new tab should be opened, unless a Search Customers tab is already open, which is a stupid limit that I artificially imposed just to show off how to work with Mediator and Workspaces.
  4. It should be possible to edit an existing Customer from the search results, unless there is a Add/Edit Customer tab already open.
  5. It should be possible to delete an existing Customer from the search results, unless the selected Customer is already open in an Add/Edit Customer tab.
  6. It should be possible to add a new Customer from the Add/Edit Customer tab, and view any errors using the error styled textboxes on the Add/Edit Customer tab.
  7. It should be possible to open an existing Customer (from search results) and start editing the Customer, and then cancel the edit, which should not only cancel the edit to the Customer, but close the Add/Edit Customer tab.
  8. It should be possible to add an Order to an existing Customer via a popup window, and view any errors using the error styled textboxes on the Add/Edit Order popup window.
  9. It should be possible to edit an Order for an existing Customer via a popup window.
  10. It should be possible to open an existing Customer's Order (from the Customer Orders list) and start editing the Order, and then cancel the edit, which should not only cancel the edit to the Order, but close the Add/Edit Order popup window.

So that's what the UI should do, and guess what, it actually does all of this. So how do we go about covering this little lot?

Well, we have covered it all before, so I think the best thing to do is list the function points above and then I will simply point you to where these things were discussed in previous Cinch articles.

Demo App Function Points

Item 1

This is achieved using a TabControl whose items are bound to a ObservableCollection<ViewModelBase> as discussed within this previous Cinch article section: CinchIII.aspx#CloseVM.

Item 2

Same as item 1, but the checking to see whether there is already an open Add/Edit Customer tab is done via the Mediator, as discussed within this previous Cinch article section: CinchII.aspx#MediatorMessaging.

Item 3

As item 2.

Item 4

As item 2, but the editing of the Customer object is achieved using the IEditableObject interface, as discussed within this previous Cinch article section: CinchII.aspx#IEditableObject.

Item 5

As item 2.

Item 6

This is done by the use of the IDataErrorInfo interface, as discussed within this previous Cinch article section: CinchII.aspx#validationRules.

Item 7

The editing of the Customer object is achieved using the IEditableObject interface, as discussed within this previous Cinch article section: CinchII.aspx#IEditableObject.

Item 8

The errors are displayed as stated in item 6 using the IDataErrorInfo interface. Handling the opening of the popup is done using the IUIVizualiserService, as discussed within thes previous Cinch article sections: CinchIII.aspx#PopServ, CinchIV.aspx#PopServ, CinchV.aspx#UIVisualizer.

Item 9

The editing of the Customer's Order object is achieved using the IEditableObject interface, as discussed within this previous Cinch article section: CinchII.aspx#IEditableObject.

Item 10

As item 7.

What's Coming Up?

In the subsequent articles, I will be showcasing it roughly like this:

  1. A code generator for developing quick Cinch ViewModels/Models, and maybe more if I find some more time. The code generator will be written in Cinch so the code generator will also serve as a second example of how to use Cinch in your own projects.

That's It Hope You Liked It

That is actually all I wanted to say right now, but I hope that from this article you can see how Cinch made the development of the demo app, er well, a "Cinch".

Thanks

As always votes / comments are welcome.

License

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

About the Author

Sacha Barber
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
 
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
 
Both of these at Sussex University UK.
 
Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

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   
QuestionWhat was MainWindow written in as I get error when I try and view it in the designermemberrwt338-Jun-10 18:25 
If I try open MainWindows.xaml in the design (VS 2008) I get an error saying "Assembly 'Cinch' was not found. Verify you are...." for the line:
xmlns:Cinch="clr-namespace:Cinch;assembly=Cinch"
I also get it for the following one.
The project builds fine and runs. Am I doing something subtly wrong here?
Awesome framework though!
Cheers,
Robert
AnswerRe: What was MainWindow written in as I get error when I try and view it in the designermvpSacha Barber8-Jun-10 21:38 
I think MainWindow does not quite know what to do with the View DataTemplates idea. Its not that easy to fix, many have complained but there is no known fix. Cinch V2 will slighly aid in this I hope. CInchV2 is coming really 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

GeneralTestsmemberAndyKernahan20-Apr-10 10:58 
Whilst the framework clearly provides some very useful features I would be nervous of using it in anything other than throw-away personal projects due to the lack of tests, otherwise; how do we know it works?
GeneralRe: TestsmvpSacha Barber20-Apr-10 20:13 
It has tests, and use or not, thats your choice. Loads of people are using it and love it, I use at work. Whatever you like 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: TestsmemberAndyKernahan20-Apr-10 21:14 
There is no need to be definsive but five test fixtures for an entire framework will not yield a high test coverage. Just my two pennies.
GeneralRe: TestsmvpSacha Barber20-Apr-10 22:41 
Each test case has loads of tests in it, and tests all of the ViewModels functions, so I know the framework is working.
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

QuestionConverted and Compiled under VS 2010, problems...memberTheArchitectmc25-Mar-10 0:51 
When I attempt to add a new customer I get the following pop-up:
 
'There was a problem fetching products'
 
Then the application locks up with close to 80% CPU usage.
 
I get the same problem when using the search customer feature:
 
'There was a problem fetching customers'
 
I have not dived into the code to see what is realling causing the problem.
 
The project was sucessfully converted to VS 2010 project with only two warnings, there was a missing assemble the Windows.Designer assembly, I replaced it with the Windows.Designer.Extensions assembly and everything compiled with out any errors.
 
Any ideas on what to possible cause of the problem is?
 
Or would you like me to debug it and get back to you since this is under 2010, and you are using 2008?
 
FYI: You still get a Five for this one!
 
~TheArch

AnswerRe: Converted and Compiled under VS 2010, problems...mvpSacha Barber25-Mar-10 1:00 
Sorry to be the bearer of bad news here, but the demo app was a throw away. It should be seen as just that. I will not be maintaining it, what would happen if I get it into VS2010 and then someone says it does not work with VS2011.
 
It should be used as a reference of how to use Cinch only. The Cinch MVVM framework is the pay load of all those articles, if that does not work, I would want to know, but as for the demo app, its a vehicle to understanding Cinch is all, and there is a good documentation around Cinch, so the demo app is not the be all and end all. Obviously its sad, but life goes on.
 
I do not what would be causing it. That is my view right now, but I will more than likely look into it as some stage, just can't say when is all. I am very busy lad these days, but it does bother me of course, but I am just too stacked up right now, to look into everything people push my way.
 
Hope you understand that.
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

QuestionFiltering ComboBox?memberdjvibri12-Mar-10 4:10 
Hi Sacha,
 
your tutorials are really helpfull to me (just started learning MVVM/WPF).
 
At the moment I'm trying to create a new textbox, where I can typ in some text and at that moment the Products dropdown box will be filtered according the product ID (which is not shown in the dropdown box).
 
I have some rare solution, but OMG it's so slow Frown | :(
 
Can you post an example about the best manner to approach this?
 
Kr,
 
Dj vibri (and I hope you still read your comments Smile | :) )
AnswerRe: Filtering ComboBox? [modified]mvpSacha Barber12-Mar-10 4:31 
You could do something like this
 
WPF AJAX Style ComboBox[^]
 
Or maybe this
 
http://www.ageektrapped.com/blog/the-missing-net-3-an-autocomplete-textbox-in-wpf-part-4-wpf-flourishes/[^]
 
or
 
WPF AutoComplete Folder TextBox[^]
 
Or Maybe this
 
http://www.ageektrapped.com/blog/the-missing-net-3-an-autocomplete-textbox-in-wpf-part-4-wpf-flourishes/[^]
 
Other than that, I have no time to look into this right now, sad to say.
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
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 Friday, March 12, 2010 10:55 AM

QuestionHow to implement application wide undo/redomembernuno8918-Oct-09 9:29 
Hi Sacha
 
I was wondering what is the best way to implement an application wide undo redo?
What I mean by application wide is :
- multiple view can issue an undo/redo
- all the views get updated when an undo takes place
 
Would implementing an undo/redo manager as a service a good idea?
Any other suggestions?
 
thanks
AnswerRe: How to implement application wide undo/redomvpSacha Barber18-Oct-09 19:24 
Thats a very big question. I fall views are binding to the same data, the IEditableObject should be enough. But if you want true undo/redo you could use the Memento Pattern, or look for some other undo/redo framework. Its really to be a question for me to answer.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

QuestionTabControlEx within an UserControl cause problem for displaying first tabmemberGautier Boder16-Oct-09 4:14 
Hi,
 
We're trying to use your TabControlEx within our application in cohabitation with the MVVM pattern but instead of having it within a Window element we declared it within an UserControl element. The result is that the first displayed tab (the one added on the application's startup) is selected but has no content shown.
 
If you look at the visual tree (using snoop) the ContentPresenter that should be showing the view matching the selected workspace viewmodel just doesn't exists at all. The Grid has no children.
 
Digging further into the implementation of your TabControlEx we've found that when you reside within a Window first the data binding is done and the only the template is applied. Being within an UserControl works exactly the opposite, first the template is applied and then only the DataBinding is done.
 
This cause the template to be applied with an empty Items collection at this point of time.
 
We don't know if this could cause the problem of my "empty" tab as when we're using the native TabControl control directly also in combination with MVVM, DataTemplate and ViewModel it works ... Weirdo isn't ? Do Microsoft have a really hidden logic within its control that isn't called just by calling the base constructor? Or is their some hidden events that we're not able to overload or handle when overwriting the control?
 
Any thoughts or digging way would be really appreciated.
 
Thanks to anyone who used this TabControlEx to post their feedback.
 
Gautier
AnswerRe: TabControlEx within an UserControl cause problem for displaying first tabmembereburke5616-Oct-09 16:09 
Add the following. For some reason, when used in a UC, you need to handle Loaded and Update the selected item. It appears that when the data bind is done, it adds a child to the PART_ItemsHolder, but then somewhere along the way, _itemsHolder.Children is cleared. I didn't look into it too much, but this should solve your issue.
 
public TabControlEx() : base()
{
// this is necessary so that we get the initial databound selected item
this.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
this.Loaded += TabControlEx_Loaded;
}
 
/// <summary>
/// in some scenarios we need to update when loaded in case the ApplyTemplate happens before
/// the databind.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void TabControlEx_Loaded(object sender, RoutedEventArgs e)
{
UpdateSelectedItem();
}
GeneralRe: TabControlEx within an UserControl cause problem for displaying first tabmembereburke5616-Oct-09 16:15 
OK, I just dug into it a little bit more. The upshot is that in the UC case, the setting of the ItemsSource *after* ApplyTemplate causes a Refresh() of the CollectionView which the ItemsControl is using. The result of this is a CollectionChanged event with Action = Reset, which my code handles and clears _itemsHolder.Children.
 
So the bottom line is: handle Loaded and update the selected item, just in case. Wink | ;)
GeneralRe: TabControlEx within an UserControl cause problem for displaying first tabmemberaaron.olds15-Nov-11 8:40 
THANK YOU!!!!!!!!!!!!! I have been looking for a solution for this for a long time.
GeneralRe: TabControlEx within an UserControl cause problem for displaying first tabmemberguton12-Aug-12 8:50 
Hi handling this.Loaded and calling UpdateSelectedItem() don't work for me
 
I use try this with john smith article http://msdn.microsoft.com/en-us/magazine/dd419663.aspx[^]
 
if in the code of the article I use TabControlEx and try to show the first tab at start-up (without the user click show-all-customer button) the first table is not displayed
 
..seems that the OnItemsChanged event with NotifyCollectionChangedAction.Reset arg cause _itemsHolder.Children.Clear(); ..this after control loaded and after windows.show() exit
 
note that if I dont try to show the first tab at start-ip and then click to the button show-all-customer all work fine
 
..I was not able to solve this
 
thanks
QuestionThe INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Order_Order\"memberdrwebmonkey11-Sep-09 8:58 
I'm getting the following error adding orders to customers
 
"ex = {"The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Order_Order\". The conflict occurred in database \"MVVM_Demo\", table \"dbo.Customer\", column 'CustomerId'.\r\nThe statement has been terminated."}"
 
I looked in the debugger to find the CustomerID is not being populated in the CurrentCustomerOrder in the ExecuteSaveOrderCommand.
 
I haven't dug through to see what is wrong. I can edit orders that are manually created in the db.
 
Thanks for the work!
AnswerRe: The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Order_Order\"mvpSacha Barber11-Sep-09 20:32 
I cant repeat this, I think this may be fixed by some change I did the other day, but am yet to upload to codeplex.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralADO.NET Entity Frameworkmemberm_zayed10-Sep-09 5:57 
First, i would like to say it is Great job, Thanks.
 
Can you give us your recomendation on using EF with this Framework, we will apreciatie it if you give us some example code in doing this.
thanks in advance.
GeneralRe: ADO.NET Entity FrameworkmvpSacha Barber10-Sep-09 21:38 
Yeah so what you would do if you want to use EF with Cinch, is just inherit from the ViewModels and add the properties to match the Model to the ViewModels.
 
I do not have time (I am a very busy man) for a code example, but it would be very easy to do, just create the model in EF (which in my mind is a service layer thing, so how would these get to the UI, via WCF, so would you need to reference the same EF dll on both client and service side).
 
And then create a ViewModel and add the properties you need to match the model and follow the instructions contained in all these articles. If you can wait a week I will have a complete code generator coming out for Cinch, that will help you enormously.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
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: ADO.NET Entity Frameworkmemberm_zayed11-Sep-09 2:47 
Ok, thanks Sacha. To me that's good news. I will wait to try using it, good luck. Smile | :)
 
Regards,
Mukhtar Zayed.
GeneralRe: ADO.NET Entity FrameworkmvpSacha Barber11-Sep-09 3:57 
I can tell you I am sure there will be no issues using it with EF at all, you will just have to create ViewModels over the EF models, but that is what Cinch is all about in a way.
 
I really think once you see the code generator in action you will just get what I mean.
 
Have a look at my blog to see some advanced screen shots showing what it will be like (its nearly done).
 
http://sachabarber.net/?p=546[^]
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
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: ADO.NET Entity Frameworkmemberm_zayed11-Sep-09 21:58 
Hi Sacha,
 
thank you again for your fast reply, i did see the code generator screen shoots, it looks nice.
I'm burning to try it really.
 
to use EF, i did modify the DataService Class to support Entities as illustrated below, and left the rest as it is.
public static List<CustomerDAL.Customer> FetchAllCustomers()
 
{
 
CustomerEntities context = new CustomerEntities();
 
return context.Customers.ToList();
 
}
 
am i right ?
 
by the way i have got the same error mentioned earlier "I get error when I open MainWindow.xaml"
 
in design time, but it works when you hit F5.
 
Thank You.
GeneralRe: ADO.NET Entity FrameworkmvpSacha Barber11-Sep-09 22:04 
yeah that should be the way.
 
The thing is the demo app was just a small demo, it is not how I would ideally structure my system. I would have data objects come from some service such as WCF, these objects would then be used to create the ViewModels to drive the UI.
 
In the demo app all the code is in one solution, and the teirs all all part of the demo Client UI app. This is not what you would want in real life I feel.
 
But yeah you could use the DataAccess layer behind a WCF service and it should still be ok.
 
Dont know about design time issue, to be honest I hand code my XAML so never work with the designer.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralI get error when I open MainWindow.xamlmemberCuongfdd2-Sep-09 15:34 
Hi Sacha,
 
I want to ask you, when I open MainWindow.xaml, it shows "Could not create an instance of type 'AddEditCustomerView'", in follow code:
 

local:AddEditCustomerView

local:SearchCustomersView
How I can fix this?
 
Thanks and Best regards.
Cuong,
GeneralRe: I get error when I open MainWindow.xamlmvpSacha Barber2-Sep-09 21:46 
Strange this works for me
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
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: I get error when I open MainWindow.xamlmemberStrattonN29-Sep-09 9:01 
Sacha,
 
Firstly thank you for all the amazing things you put together for us in the growing world of WPF. I am grateful for your amazing work, you are the best.
 
Working my way through Cinch but I also get the "Could not create an instance of type 'AddEditCustomerView'" error. Any ideas? The application will run just can't edit the MainWindow.xaml page. Problem is for the local: line
 
            <DataTemplate DataType="{x:Type VM:AddEditCustomerViewModel}">
                  <AdornerDecorator>
                        <local:AddEditCustomerView />
                  </AdornerDecorator>
            </DataTemplate>
 
The second Cinch in the xmlns line is red, with a tooltip saying "Cannot resolve symbol 'Cinch'"
 
      xmlns:Cinch="clr-namespace:Cinch;assembly=Cinch"
 
If I try to add a reference to Cinch it enters exactly the same format but says it cannot resolve it.
 
Thanks,
Nigel Stratton
GeneralSolution to : I get error when I open MainWindow.xaml [modified]membersergezab17-Nov-09 11:34 
To resolve the issue it is necessary to replace "StaticResource" keyword to "DynamicResource" in following places:
 
<SearchCustomersView.xaml>
 
   Style="{StaticResource ValidatingTextBox}"
ItemContainerStyle="{StaticResource ListViewContainer}"
ColumnHeaderContainerStyle="{StaticResource GridViewColumnHeaderStyle}">
ItemContainerStyle="{StaticResource ContextMenuItemStyle}"
 
<AddEditCustomerView.xaml>
All instances of StaticResource have to be replaced with DynamicResource
 
modified on Wednesday, November 18, 2009 1:33 PM

GeneralRe: I get error when I open MainWindow.xamlmembercycleguy6-Oct-09 9:56 
I also received this same error.
QuestionCanceled data displayed in viewsmemberno cars go1-Sep-09 14:37 
Hi Sacha,
 
on your demo app, when an edit is canceled, the view is not updated (the canceled changes are still displayed until the view is recreated). Is this an expected behavior ?
 
Thanks for sharing Thumbs Up | :thumbsup:
 
Fred (from France)
AnswerRe: Canceled data displayed in viewsmvpSacha Barber1-Sep-09 21:34 
Yeah it kind of is, but now that you mention it it probably needs looking at. Il put it on the list.
 
Thanks for pointing it out.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

AnswerRe: Canceled data displayed in viewsmvpSacha Barber2-Sep-09 10:29 
I have fixed this and updated code, which I will be updating on site soon.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
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: Canceled data displayed in viewsmemberno cars go2-Sep-09 11:23 
Cool ! Cool | :cool:
GeneralOrders view updated, but customer list view still need refreshmemberno cars go5-Sep-09 7:26 
Hi Sacha,
 
I saw you've updated your code. It's ok for views related to orders but customer's list view still need refresh after a cancelled edition.
 
However, your demo is very impressive and useful to learn mvvm principles !
GeneralRe: Orders view updated, but customer list view still need refreshmvpSacha Barber5-Sep-09 21:37 
I checked out the Customers and that is right in my opinion, what happens is that the Customer being edited is closed, which is right.
 

no cars go wrote:
However, your demo is very impressive and useful to learn mvvm principles !

 
You know one thing I should say, the demo is just that, it is just a demo, the real payload was the Cinch.Dll. I have had people criticise my unit tests and say they are sh*t and they are not granular enough (they are one test per command I dont know how much more granular they can be).
 
Anyway what I mean is criticism is fine and if it is plainly wrong like the one you stated was, that's fine, but don't miss the point, which is how to develop MVVM apps using Cinch.
 
I am currently working on improving it all a bit actually and am concentrating on making DataWrappers easier to work with, and am also 90% done with creating a code generator that creats Cinch ViewModels rather nicely.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralWrong return commandmemberMaC_Premium25-Aug-09 23:50 
In ViewModelBase.cs
 

/// <summary>
/// UnloadedCommand : Window/UserControl Lifetime command
/// </summary>
public SimpleCommand UnloadedCommand
{
get { return loadedCommand; }
}

GeneralRe: Wrong return commandmvpSacha Barber26-Aug-09 2:18 
Shite, Ill fix that, soon and re-upload
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
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: Wrong return commandmvpSacha Barber26-Aug-09 3:21 
This should be done in 1 minute
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralSilverlightmemberMember 282437725-Aug-09 10:57 
Hello Sacha,
 
i very impressive, great job.
 
I want to ask you, do you have same project but to Silverlight???
 
I looking projects like this to silverlight in vb or C#.
 

fausto
GeneralRe: SilverlightmvpSacha Barber25-Aug-09 21:46 
Sadly no. Best bet is use Laurents SL framework
 
http://www.galasoft.ch/mvvm/getstarted/[^]
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

QuestionHow to add Separater to WPFMenuItem?memberMaC_Premium25-Aug-09 1:16 
Hi, Sacha Smile | :)
 
How to add Separater to WPFMenuItem?
 
Thanks
AnswerRe: How to add Separater to WPFMenuItem?mvpSacha Barber25-Aug-09 2:14 
Yeah that would be hard using Cinchs approach, I dont think that would be possible. You could maybe do it using a ValueConverter, but other than that I don't think it would be possible.
 
Its a trade off, of course, being able to do everything in ViewModel sometimes means making sacrifices in some areas.
 
I think Karl may have touched on this in his article
 
http://karlshifflett.wordpress.com/2008/02/03/wpf-sample-series-databound-hierarchicaldatatemplate-menu-sample/[^]
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralI am enjoying this...memberRajesh Pillai23-Aug-09 5:52 
5 again Smile | :)
 
Enjoy Life,
Rajesh Pillai
http://rajeshpillai.blogspot.com/
http://simply-url.blogspot.com/

 

GeneralRe: I am enjoying this...mvpSacha Barber23-Aug-09 6:32 
Thanks man
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
 
My Blog : sachabarber.net

GeneralQuestion on Microsoft.VisualStudio.TeamSystem.Data.UnitTesting and minor commentmemberpspidey18-Aug-09 5:10 
Sacha, I seem to be having a bit of an issue with a missing dependency for the Cinch project file on:
Microsoft.VisualStudio.TeamSystem.Data.UnitTesting
 
I have VS 2008 Team System Development Edition installed on my system. I'm wondering if this missing dependency is from a different version of Visual studio - IIRC, there's a number of different team system versions.
 
Do you know if that's the reason I'm missing the dependency?... I'm wondering where I could get a hold of this assembly.
 
Also, I notice that the references from the various project files in the demo solution to Cinch are binary references. I was wondering particularly given the solution includes the Cinch project, wouldn't it be better for these references to be project references instead?
 
Thanks,
Phil
GeneralRe: Question on Microsoft.VisualStudio.TeamSystem.Data.UnitTesting and minor commentmemberpspidey18-Aug-09 5:14 
Hmm, is the TeamSystem.Data.UnitTesting really a dependency? I just removed this assembly reference and rebuilt the solution, and it built without errors.
 
Phil
GeneralRe: Question on Microsoft.VisualStudio.TeamSystem.Data.UnitTesting and minor commentmvpSacha Barber18-Aug-09 5:25 
That seems to be weird, that could be a TFS thing. I actually built the app at home using Test Driven .NET and that is the reference that should be used.
 
As far as Binary vs Project references, I just do it like that, change that if you like it shouldn't matter.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008/2009
  • Codeproject MVP 2008/2009
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: Question on Microsoft.VisualStudio.TeamSystem.Data.UnitTesting and minor commentmemberpspidey18-Aug-09 5:53 
Thanks Sacha.
 
Another quick question Wink | ;) ..
 
Do you use the cider editor for design? I can view most of the demo app's views (AddEditCustomerView) etc. in the cider designer but with the main window (MainWindow) the cider designer is complaining of being unable to create an instance of AddEditCustomerView.
 
Having attached another debugger to the visual studio process, what's causing it problems is the references from these views (AddEditCustomerView) to resources included by App.xaml.
 
I think I've seen this kind of thing previously and the way I've gotten around it sometimes is to use DynamicResource references instead of StaticResource.
 
Do you have any recommendations on this? Just avoid using cider completely? Change all the problematic references to use DynamicResource (looks like there might be quite a few).
 
Or am I just doing something stupid?
 
Thanks again,
Phil
GeneralRe: Question on Microsoft.VisualStudio.TeamSystem.Data.UnitTesting and minor commentmemberpspidey18-Aug-09 6:00 
And I guess, another alternative would be to duplicate the merge resource dictionary references into each of the user controls resource dictionaries. Ugly, but I've done this kind of thing before in order to have the designer reflect theme styling when editing user controls.
 
The cider designer has a long way to go...
 
Phil

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.130617.1 | Last Updated 5 Sep 2009
Article Copyright 2009 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid