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. Selected Value in Combobox

Selected Value in Combobox

Scheduled Pinned Locked Moved WPF
4 Posts 4 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.
  • Y Offline
    Y Offline
    yogesh_kumar_agarwal
    wrote on last edited by
    #1

    Dear All, Here is my combobox in Silverlight <ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber"> and i use drpUserList.ItemsSource = e.Result; To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value.

    A A K 3 Replies Last reply
    0
    • Y yogesh_kumar_agarwal

      Dear All, Here is my combobox in Silverlight <ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber"> and i use drpUserList.ItemsSource = e.Result; To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value.

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

      Have a look at this post[^].

      The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick - Silverlight *.XCP files

      1 Reply Last reply
      0
      • Y yogesh_kumar_agarwal

        Dear All, Here is my combobox in Silverlight <ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber"> and i use drpUserList.ItemsSource = e.Result; To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value.

        A Offline
        A Offline
        Arun Jacob
        wrote on last edited by
        #3

        You can directly bind from XAML like this, SelectedValue="{Binding UserID}"

        Arun Jacob My Technical Blog : Code.NET

        1 Reply Last reply
        0
        • Y yogesh_kumar_agarwal

          Dear All, Here is my combobox in Silverlight <ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber"> and i use drpUserList.ItemsSource = e.Result; To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value.

          K Offline
          K Offline
          Kunal Chowdhury IN
          wrote on last edited by
          #4

          Do the following:

          var selectedUser = (from user in usersList
          where user.UserId.Equals(selectedUserId)
          select user).FirstOrDefault();

          drpUserList.SelectedItem = selectedUser;

          Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


          Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

          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