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. Editing multiple item types in the same control

Editing multiple item types in the same control

Scheduled Pinned Locked Moved WPF
helpwpfquestionwinformswcf
2 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.
  • G Offline
    G Offline
    gantww
    wrote on last edited by
    #1

    Greetings, I'm trying to throw together a quick silverlight proof of concept, but I'm stuck on a slight issue. Let's say I have a base class (we'll call it Mammal) and two derived classes (dog and cat, respectively). I have an ObservableList<Mammal> that holds a whole bunch of cats and dogs. Now, I have a listbox defined like so: <ListBox x:name="lstMammals"> ... </ListBox> A little ways further down, I have a ContentControl (I'm not sure if this is the right control to use here) that contains a StackPanel with two user controls in it. One of the user controls handles dogs and the other cats. How do I do the binding in XAML in such a way that when I select an item in the listbox that the appropriate user control pops up for editing it? Or am I looking at the problem wrong? Thanks, Will

    M 1 Reply Last reply
    0
    • G gantww

      Greetings, I'm trying to throw together a quick silverlight proof of concept, but I'm stuck on a slight issue. Let's say I have a base class (we'll call it Mammal) and two derived classes (dog and cat, respectively). I have an ObservableList<Mammal> that holds a whole bunch of cats and dogs. Now, I have a listbox defined like so: <ListBox x:name="lstMammals"> ... </ListBox> A little ways further down, I have a ContentControl (I'm not sure if this is the right control to use here) that contains a StackPanel with two user controls in it. One of the user controls handles dogs and the other cats. How do I do the binding in XAML in such a way that when I select an item in the listbox that the appropriate user control pops up for editing it? Or am I looking at the problem wrong? Thanks, Will

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      It sounds like you want a master/detail scenario... Unfortunately, Silverlight doesn't support the rich, flexible data template bindings to do this like WPF has, so you'll need a little code. You can handle the listbox's selectionchanged event, and in your handler show a detail control appropriate for the type of the selected item. A search on "Silverlight master detail" yields several examples, like this one: Using User Controls to Implement Master/Detail Scenarios[^]

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      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