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. WPF ComboBox using Llinq

WPF ComboBox using Llinq

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

    Hi , I plaved a combobox and a listbox in a .xaml page. I used LINQ to fill combobox. I want the selected value to be displayed in the textbox. But i am getting object and not the exact value.I used like this, var value=additem.selectedItem; text1.text=value.ToString(); Pls help me! :(

    Gomathi R

    A 1 Reply Last reply
    0
    • G GomathiR

      Hi , I plaved a combobox and a listbox in a .xaml page. I used LINQ to fill combobox. I want the selected value to be displayed in the textbox. But i am getting object and not the exact value.I used like this, var value=additem.selectedItem; text1.text=value.ToString(); Pls help me! :(

      Gomathi R

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      GomathiR wrote:

      text1.text=value.ToString();N/blockquote> Because you are doing a ToString() on the object. You would need to use the objects porperty value. e.g.

      var value=additem.SelectedItem as YourObject; //YourObject is the object type which is the databound for each item
      text1.text = value.PropertyInYourObject;

      You can do it in XAML itself also, databinding the Text property of text1. See if this works,

      Text = ="{Binding ElementName=additem,Path=SelectedItem}"

      B G 2 Replies Last reply
      0
      • A ABitSmart

        GomathiR wrote:

        text1.text=value.ToString();N/blockquote> Because you are doing a ToString() on the object. You would need to use the objects porperty value. e.g.

        var value=additem.SelectedItem as YourObject; //YourObject is the object type which is the databound for each item
        text1.text = value.PropertyInYourObject;

        You can do it in XAML itself also, databinding the Text property of text1. See if this works,

        Text = ="{Binding ElementName=additem,Path=SelectedItem}"

        B Offline
        B Offline
        BlitzPackage
        wrote on last edited by
        #3

        Great answer!

        1 Reply Last reply
        0
        • A ABitSmart

          GomathiR wrote:

          text1.text=value.ToString();N/blockquote> Because you are doing a ToString() on the object. You would need to use the objects porperty value. e.g.

          var value=additem.SelectedItem as YourObject; //YourObject is the object type which is the databound for each item
          text1.text = value.PropertyInYourObject;

          You can do it in XAML itself also, databinding the Text property of text1. See if this works,

          Text = ="{Binding ElementName=additem,Path=SelectedItem}"

          G Offline
          G Offline
          GomathiR
          wrote on last edited by
          #4

          Hi, thank u very much for your help. Its working now. :)

          Gomathi R

          A 1 Reply Last reply
          0
          • G GomathiR

            Hi, thank u very much for your help. Its working now. :)

            Gomathi R

            A Offline
            A Offline
            ABitSmart
            wrote on last edited by
            #5

            Glad to be of help.

            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