In WPF,MVVM should ViewModel be involved in opening a window, e.g. About-window?

To the Title-question: Yes. The VM of the Main View should show the AboutBox.

Up vote 2 down vote favorite share g+ share fb share tw.

I have a standard WPF treeview and have bound items to view model classes. I now wish to handle behaviour when items are double-clicked (opening documents visual-studio-style). I can get event-handler to fire in the control housing the treeview (xaml shown), but how do I bind to specific behaviour on the view model classes - e.g. ProjectViewModel?

Preferable bound to ICommand-implementer, as this is used elsewhere... Thanks for any comments, Anders, Denmark c# wpf treeview command link|improve this question edited Jan 5 '11 at 19:55 asked Dec 19 '10 at 18:28Anders Juul492415 89% accept rate.

To the Title-question: Yes. The VM of the Main View should show the AboutBox. But the body of the message seems different, maybe you can expand on it a little?

Sorry - I got two questions mixed up there! – Anders Juul Dec 20 '10 at 7:02 As for the question in the 'body': I have viewmodel-objects handling the individual treeitems with regards to display, lazy load etc. However, when I want to 'activate'/double-click an item in the treeview, I'd like this action to be handled by the same viewmodel objects that handle the display - but how do I do that? – Anders Juul Dec 20 '10 at 7:05 I marked this as answered as the title question got answered.

The 'body' question has been reposted here. Sorry for any inconveneince (hard word ;-) ) – Anders Juul Dec 21 '10 at 9:32 I guess this might end up confusing people. Why not edit the question to describe the original issue - you reposted the ther question, right?

Cheers.... – Sebastian Edelmeier Jun 1 '11 at 5:48.

The preferred way to do this is to use the command pattern as you already mentionend. I.e. To bind to an ICommand implementation via a dependency property.

Dependency properties are actually implemented by a static backing property which implements the dependency stuff used by the framework. Unfortunately the way MS decided to implement the backing property is - well, not optimal to say the least. It is hooked up to the public, non-static property you bind to in xaml - by means of a hardcoded string... I don't remember where but I found a quite elegant solution to the static/non-static relationship which uses a lambda expression to do the mapping thus completely removing the hardcoded, error prone string mapping.

If you still need it I can send you some more info on this. You know where to reach me :-) Another concern you will need to adress is to abstract away the implementation of the view to maintain testability.

Thanks for adding your comments! I think I have a satisfactory solution now even though mapping is done through string literals in XAML as you point out. I do think that the added complexity from mapping via some fancy lambda expression would not be worth it.

Have we had this discussion before ;-)? Still - thanks, see you soon. – Anders Juul Feb 9 '11 at 11:48.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions