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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. Help with a WPF Combobox

Help with a WPF Combobox

Scheduled Pinned Locked Moved WPF
csharpwpfgame-devhelpquestion
13 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.
  • A Offline
    A Offline
    Aaron Hickman
    wrote on last edited by
    #1

    Hi all, I am really new to WPF and I am trying to create a combo box that has the ability to display an ellipses character if the text is too long (for the selected item). Can anyone help? Electronics, Game Systems, Cameras & Photo Computers and Networking Clothing, Shoes, and Accessories Books, Music, Movies, DVDs, and Video Games All Other Categories -Aaron

    L 1 Reply Last reply
    0
    • A Aaron Hickman

      Hi all, I am really new to WPF and I am trying to create a combo box that has the ability to display an ellipses character if the text is too long (for the selected item). Can anyone help? Electronics, Game Systems, Cameras & Photo Computers and Networking Clothing, Shoes, and Accessories Books, Music, Movies, DVDs, and Video Games All Other Categories -Aaron

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Have a look at this article: http://www.designerwpf.com/2008/02/04/how-do-i-wrap-text-in-the-combobox/[^] I found this using www.live.com and seached for: wpf combobox texttrimming

      Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

      Just a grain of sand on the worlds beaches.

      A 1 Reply Last reply
      0
      • L Lost User

        Have a look at this article: http://www.designerwpf.com/2008/02/04/how-do-i-wrap-text-in-the-combobox/[^] I found this using www.live.com and seached for: wpf combobox texttrimming

        Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

        Just a grain of sand on the worlds beaches.

        A Offline
        A Offline
        Aaron Hickman
        wrote on last edited by
        #3

        Hi Karl, Thank you for the reply. I actually did see this article before posting. I could not get it to work. How do I set the DataTemplate for the combobox?

        L 1 Reply Last reply
        0
        • A Aaron Hickman

          Hi Karl, Thank you for the reply. I actually did see this article before posting. I could not get it to work. How do I set the DataTemplate for the combobox?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Here is a code snippet from one of my programs. Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page Just a grain of sand on the worlds beaches.

          A 1 Reply Last reply
          0
          • L Lost User

            Here is a code snippet from one of my programs. Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page Just a grain of sand on the worlds beaches.

            A Offline
            A Offline
            Aaron Hickman
            wrote on last edited by
            #5

            hmm. I must have something wrong. My code is below. When I select the item that is longer than the width of the combobox it does not show the ellipsis characters. Any thing that you can see that I am doing wrong? Electronics, Game Systems, Cameras & Photo Computers and Networking Clothing, Shoes, and Accessories Books, Music, Movies, DVDs, and Video Games All Other Categories

            L 1 Reply Last reply
            0
            • A Aaron Hickman

              hmm. I must have something wrong. My code is below. When I select the item that is longer than the width of the combobox it does not show the ellipsis characters. Any thing that you can see that I am doing wrong? Electronics, Game Systems, Cameras & Photo Computers and Networking Clothing, Shoes, and Accessories Books, Music, Movies, DVDs, and Video Games All Other Categories

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I see what you mean. I have a hack, but want to give you a better solution. I'm in the middle to posting a new version of XAML Power Toys, so I'll get back to this tomorrow night after work. For now, move ahead, we'll get this.

              Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

              Just a grain of sand on the worlds beaches.

              A 1 Reply Last reply
              0
              • L Lost User

                I see what you mean. I have a hack, but want to give you a better solution. I'm in the middle to posting a new version of XAML Power Toys, so I'll get back to this tomorrow night after work. For now, move ahead, we'll get this.

                Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

                Just a grain of sand on the worlds beaches.

                A Offline
                A Offline
                Aaron Hickman
                wrote on last edited by
                #7

                Thanks Karl, You Rock! :-D

                L 3 Replies Last reply
                0
                • A Aaron Hickman

                  Thanks Karl, You Rock! :-D

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Aaron, I've spent the entire weekend updating XAML Power Toys for Silverlight and just published it. I'll hop on this Monday after work. I'm just plain beat and brain is out of gas. I need my creative gas tank full to give you a solution that is not hacky.

                  Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

                  Just a grain of sand on the worlds beaches.

                  C 1 Reply Last reply
                  0
                  • L Lost User

                    Aaron, I've spent the entire weekend updating XAML Power Toys for Silverlight and just published it. I'll hop on this Monday after work. I'm just plain beat and brain is out of gas. I need my creative gas tank full to give you a solution that is not hacky.

                    Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

                    Just a grain of sand on the worlds beaches.

                    C Offline
                    C Offline
                    ColinM123
                    wrote on last edited by
                    #9

                    Perhaps you can use a valueconverter (erm.. somewhere)

                    1 Reply Last reply
                    0
                    • A Aaron Hickman

                      Thanks Karl, You Rock! :-D

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Aaron, I've spent and hour got it to work but it had an unexpected behavior. So I'm retemplating the ComboBox to support this. I had to download Blend to do this. Should be another hour or so.

                      Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

                      Just a grain of sand on the worlds beaches.

                      1 Reply Last reply
                      0
                      • A Aaron Hickman

                        Thanks Karl, You Rock! :-D

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        Below are two solutions. One when the ComboBox ItemSource is data bound. The second when the ComboBox items are added in-line. You can thank Code Project MVP Josh Smith for this solution. He is the real, "Man" and Mr. WPF. Josh's blog: http://joshsmithonwpf.wordpress.com/ <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="{TemplateBinding Content}" TextTrimming="CharacterEllipsis"/> </DataTemplate> </Setter.Value> </Setter> Greetings from the planet known as Earth Thanks to Josh Smith for this tip! Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page Just a grain of sand on the worlds beaches.

                        A 1 Reply Last reply
                        0
                        • L Lost User

                          Below are two solutions. One when the ComboBox ItemSource is data bound. The second when the ComboBox items are added in-line. You can thank Code Project MVP Josh Smith for this solution. He is the real, "Man" and Mr. WPF. Josh's blog: http://joshsmithonwpf.wordpress.com/ <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="{TemplateBinding Content}" TextTrimming="CharacterEllipsis"/> </DataTemplate> </Setter.Value> </Setter> Greetings from the planet known as Earth Thanks to Josh Smith for this tip! Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page Just a grain of sand on the worlds beaches.

                          A Offline
                          A Offline
                          Aaron Hickman
                          wrote on last edited by
                          #12

                          I was just checking up on your blog. Good stuff. I really appreciate your help with this. I had a little bit of both in my attempts, I just could never get the right "combo". Thanks again.

                          L 1 Reply Last reply
                          0
                          • A Aaron Hickman

                            I was just checking up on your blog. Good stuff. I really appreciate your help with this. I had a little bit of both in my attempts, I just could never get the right "combo". Thanks again.

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #13

                            Anytime.

                            Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

                            Just a grain of sand on the worlds beaches.

                            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