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. General Programming
  3. WPF
  4. how to get selected datagrid row items ?

how to get selected datagrid row items ?

Scheduled Pinned Locked Moved WPF
wpfcsharpregexarchitecturetutorial
4 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    SRKSHOME
    wrote on last edited by
    #1

    Hi, I have a datagrid(using WPF) and miltiple row selection is allowed. How to get multiple selected items in MVVM pattern? It is easy to get this in code behind file? But in MVVM pattern codebehind file doesn't contains the much code. Many thanks.

    P 1 Reply Last reply
    0
    • S SRKSHOME

      Hi, I have a datagrid(using WPF) and miltiple row selection is allowed. How to get multiple selected items in MVVM pattern? It is easy to get this in code behind file? But in MVVM pattern codebehind file doesn't contains the much code. Many thanks.

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

      There are two parts to this answer. The first part is that you should use a Command to set an IsSelected property on each item in your collection. The second part compensates for the fact you can't bind to a command on the Selected event. To get round this you need to use an EventToCommand Blend Behaviour. Laurent Bugnion has a fine sample in MVVM Light.

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      S 1 Reply Last reply
      0
      • P Pete OHanlon

        There are two parts to this answer. The first part is that you should use a Command to set an IsSelected property on each item in your collection. The second part compensates for the fact you can't bind to a command on the Selected event. To get round this you need to use an EventToCommand Blend Behaviour. Laurent Bugnion has a fine sample in MVVM Light.

        Forgive your enemies - it messes with their heads

        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

        S Offline
        S Offline
        SRKSHOME
        wrote on last edited by
        #3

        thanks..Can I have that link? I couldn't get it.

        P 1 Reply Last reply
        0
        • S SRKSHOME

          thanks..Can I have that link? I couldn't get it.

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

          You can find it here[^].

          Forgive your enemies - it messes with their heads

          My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

          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