Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. MVVM Best Practise

MVVM Best Practise

Scheduled Pinned Locked Moved The Lounge
questionwpfarchitecture
18 Posts 10 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David Ceder
    wrote on last edited by
    #1

    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?

    L OriginalGriffO S M P 5 Replies Last reply
    0
    • D David Ceder

      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?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You could start by reading the prologue at the top of this page.

      M 1 Reply Last reply
      0
      • D David Ceder

        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?

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3
        1. Learn to read. 2) Learn to pay attention. It's in red letters at the top of the page - it's not like we hide it in a footnote! 3) Then ask in the right place, and you might not annoy the people you want help from...http://www.codeproject.com/Questions/ask.aspx[^]

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • D David Ceder

          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?

          S Offline
          S Offline
          Slacker007
          wrote on last edited by
          #4

          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.

          OriginalGriffO L 2 Replies Last reply
          0
          • S Slacker007

            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.

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            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...

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            S T M 3 Replies Last reply
            0
            • OriginalGriffO OriginalGriff

              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...

              S Offline
              S Offline
              Slacker007
              wrote on last edited by
              #6

              You can come off your high horse now. :sigh:

              OriginalGriffO J 2 Replies Last reply
              0
              • S Slacker007

                You can come off your high horse now. :sigh:

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                I never use horses - smelly big objects with no brakes and less brains! ;)

                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  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...

                  T Offline
                  T Offline
                  Tom Deketelaere
                  wrote on last edited by
                  #8

                  Actually

                  OriginalGriff wrote:

                  To "Community", then to the Lounge

                  If you just click the community main menu you automatically come to the lounge. Taken that into consideration it might sometimes make people just skip the rest and just ask the community. Of course no excuse for not reading the big red letters but...

                  Tom

                  1 Reply Last reply
                  0
                  • L Lost User

                    You could start by reading the prologue at the top of this page.

                    M Offline
                    M Offline
                    Mark_Wallace
                    wrote on last edited by
                    #9

                    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!

                    L 1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      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...

                      M Offline
                      M Offline
                      Mark_Wallace
                      wrote on last edited by
                      #10

                      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!

                      OriginalGriffO D 2 Replies Last reply
                      0
                      • D David Ceder

                        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?

                        M Offline
                        M Offline
                        Marc Clifton
                        wrote on last edited by
                        #11

                        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: Marc

                        Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!

                        1 Reply Last reply
                        0
                        • S Slacker007

                          You can come off your high horse now. :sigh:

                          J Offline
                          J Offline
                          JimmyRopes
                          wrote on last edited by
                          #12

                          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

                          1 Reply Last reply
                          0
                          • D David Ceder

                            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?

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #13

                            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.

                            1 Reply Last reply
                            0
                            • M Mark_Wallace

                              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!

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #14

                              'Ere, no, listen, er ... and you, mush.

                              1 Reply Last reply
                              0
                              • M Mark_Wallace

                                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!

                                OriginalGriffO Offline
                                OriginalGriffO Offline
                                OriginalGriff
                                wrote on last edited by
                                #15

                                It makes sense if you are left handed...

                                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                1 Reply Last reply
                                0
                                • S Slacker007

                                  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.

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #16

                                  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.

                                  1 Reply Last reply
                                  0
                                  • M Mark_Wallace

                                    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!

                                    D Offline
                                    D Offline
                                    Daniel Pfeffer
                                    wrote on last edited by
                                    #17

                                    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

                                    M 1 Reply Last reply
                                    0
                                    • D Daniel Pfeffer

                                      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

                                      M Offline
                                      M Offline
                                      Mark_Wallace
                                      wrote on last edited by
                                      #18

                                      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!

                                      1 Reply Last reply
                                      0
                                      Reply
                                      • Reply as topic
                                      Log in to reply
                                      • Oldest to Newest
                                      • Newest to Oldest
                                      • Most Votes


                                      • Login

                                      • Don't have an account? Register

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • World
                                      • Users
                                      • Groups