MVVM Best Practise
-
Richard MacCutchan wrote:
prologue
I can't see that word without hearing Frankie Howerd's voice.
I wanna be a eunuchs developer! Pass me a bread knife!
-
To get to the Lounge to post his question, he would start at the Home page, and go via the menu. Past "Articles" - where he could find an answer. Past "Quick Answers" - where he could get an answer. Past "Discussions" - where he could get an answer. To "Community", then to the Lounge - where it says clearly at the top of the page in bright red writing "click here to ask your programming question" So if he misses all those subtle clues, a little mild rebuke is probably the least of his problems! :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
Ah, but what if he's Jewish! Them awkward buggers read from right to left -- something that makes absolutely no sense to me whatsoever. It's totally illogical. Must be why they're all lawyers.
I wanna be a eunuchs developer! Pass me a bread knife!
-
I have code in my view that reacts to a double-click on a listview so that the next successive parent of the SelectedItem being double-clicked is displayed. At the same time, other listviews which are synchronized to the SelectedItem(a ViewModel) of the listview being clicked shows the related ViewModel records. How can I best separate this out in MVVM so there is no code in my view?
David Ceder wrote:
How can I best separate this out in MVVM so there is no code in my view?
First off, you need to learn how interrupts work on an x86 architecture CPU. Once you've mastered that, you should learn about user mode threads (see here[^], I should get a 5 for this post just for that link). Once you've mastered all that, you still need to figure out how to get the actual address in memory of you ViewModel -- a combination of
fixed
and P/Invoke should help. Now you've got the pieces in place for writing a user thread monitor to check for changes in your ViewModel and call other functions to update when the data changes. Oops, I forgot to mention, you'll have to figure out how get the address of functions in the IL, and how to marshal back onto the main thread because the UI really shouldn't be updated on a worker thread. Gads. So much work for something that would be so easy to do if the C# language designers had simply implemented property change events. :doh: MarcImperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
-
You can come off your high horse now. :sigh:
Slacker007 wrote:
You can come off your high horse :baaaa!: now.
FTFY :-D
Once you lose your pride the rest is easy. In the end, only three things matter: how much you loved, how gently you lived, and how gracefully you let go of things not meant for you. – Buddha Simply Elegant Designs JimmyRopes Designs
-
I have code in my view that reacts to a double-click on a listview so that the next successive parent of the SelectedItem being double-clicked is displayed. At the same time, other listviews which are synchronized to the SelectedItem(a ViewModel) of the listview being clicked shows the related ViewModel records. How can I best separate this out in MVVM so there is no code in my view?
I assume you're asking how you can accomplish this without code-behind, rather than no code in your view at all. XAML is code. What you're looking to do is to create a command in your ViewModel using one of the many ICommand implementations around, such as Josh Smith's RelayCommand. Once you have the command, you're going to need an EventToCommand implementation (there's one available in the System.Windows.Interactivity assembly) that you will bind the double-click on the ListView to your command.
-
Richard MacCutchan wrote:
prologue
I can't see that word without hearing Frankie Howerd's voice.
I wanna be a eunuchs developer! Pass me a bread knife!
-
Ah, but what if he's Jewish! Them awkward buggers read from right to left -- something that makes absolutely no sense to me whatsoever. It's totally illogical. Must be why they're all lawyers.
I wanna be a eunuchs developer! Pass me a bread knife!
It makes sense if you are left handed...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Checkout the articles on this site, there are many. Just search for MVVM under articles in the search tool. I think trying to solve your problem on your own, with the aid of these articles, is the best way for you to learn; which is what this site is all about. As you already see, their are some senior members here who are not so polite to those who post questions in the sacred Lounge. Sorry for that. Best of luck.
Slacker007 wrote:
members here who are not so polite to those who post questions in the sacred Lounge
It's nothing to do with being sacred, it's about reading and thinking, before randomly dumping a message. Something far too many people these days seem incapable of doing for themselves.
-
Ah, but what if he's Jewish! Them awkward buggers read from right to left -- something that makes absolutely no sense to me whatsoever. It's totally illogical. Must be why they're all lawyers.
I wanna be a eunuchs developer! Pass me a bread knife!
Mark_Wallace wrote:
Ah, but what if he's Jewish! Them awkward buggers read from right to left -- something that makes absolutely no sense to me whatsoever. It's totally illogical. Must be why they're all lawyers.
The most common languages written right to left are Arabic, Persian, and Urdu, not Hebrew. http://en.wikipedia.org/wiki/Right-to-left[^] Would you care to amend your remarks, in this light? :)
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill
-
Mark_Wallace wrote:
Ah, but what if he's Jewish! Them awkward buggers read from right to left -- something that makes absolutely no sense to me whatsoever. It's totally illogical. Must be why they're all lawyers.
The most common languages written right to left are Arabic, Persian, and Urdu, not Hebrew. http://en.wikipedia.org/wiki/Right-to-left[^] Would you care to amend your remarks, in this light? :)
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill
Not at all! If I've got a choice between facts that I make up or facts that wikipedia makes up, I'll choose my invented facts, any day!
I wanna be a eunuchs developer! Pass me a bread knife!