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. Silverlight listbox selected item template

Silverlight listbox selected item template

Scheduled Pinned Locked Moved WPF
tutorialquestion
3 Posts 3 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.
  • U Offline
    U Offline
    USAFHokie80
    wrote on last edited by
    #1

    Hi... So I want to change the item template for the selected item of a listbox. I know I need to use the VisualStatemanager to do this, but I'm not sure how to do it. All of the example I've found seem to be much more complicated than I need and/or I can't get them to work. Basically, for an unselected item, I need to display the name property. And for a selected item I need to display a few other things. So My understanding is that I should use two different grids, and use the VisualState to turn toggle the visibility of the "detail" info. Can someone throw me a simple example? Thanks.

    S A 2 Replies Last reply
    0
    • U USAFHokie80

      Hi... So I want to change the item template for the selected item of a listbox. I know I need to use the VisualStatemanager to do this, but I'm not sure how to do it. All of the example I've found seem to be much more complicated than I need and/or I can't get them to work. Basically, for an unselected item, I need to display the name property. And for a selected item I need to display a few other things. So My understanding is that I should use two different grids, and use the VisualState to turn toggle the visibility of the "detail" info. Can someone throw me a simple example? Thanks.

      S Offline
      S Offline
      SledgeHammer01
      wrote on last edited by
      #2

      USAFHokie80 wrote:

      Hi... So I want to change the item template for the selected item of a listbox. I know I need to use the VisualStatemanager to do this, but I'm not sure how to do it. All of the example I've found seem to be much more complicated than I need and/or I can't get them to work.
       
      Basically, for an unselected item, I need to display the name property. And for a selected item I need to display a few other things. So My understanding is that I should use two different grids, and use the VisualState to turn toggle the visibility of the "detail" info. Can someone throw me a simple example?

      No, you do not use VisualStateManager for this. There are two ways to go about this. If you want to keep your selected item and unselected item template completely separate, you can define two separate DataTemplates (selected & unselected) and swap them out in ListBoxItem via a trigger. It sounds like what would be better in your case is to have a single template where you just collapse visibility on the stuff you don't want to show via a trigger.

      1 Reply Last reply
      0
      • U USAFHokie80

        Hi... So I want to change the item template for the selected item of a listbox. I know I need to use the VisualStatemanager to do this, but I'm not sure how to do it. All of the example I've found seem to be much more complicated than I need and/or I can't get them to work. Basically, for an unselected item, I need to display the name property. And for a selected item I need to display a few other things. So My understanding is that I should use two different grids, and use the VisualState to turn toggle the visibility of the "detail" info. Can someone throw me a simple example? Thanks.

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        Modify the style of the ListBox. Check this[^] out for a listing of styles / templates associated to the ListBox item.

        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