Click here to Skip to main content
15,900,461 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Help with a WPF Combobox Pin
User 2710092-Oct-08 17:11
User 2710092-Oct-08 17:11 
GeneralRe: Help with a WPF Combobox Pin
Aaron Hickman2-Oct-08 17:58
Aaron Hickman2-Oct-08 17:58 
GeneralRe: Help with a WPF Combobox Pin
User 2710092-Oct-08 18:28
User 2710092-Oct-08 18:28 
GeneralRe: Help with a WPF Combobox Pin
Aaron Hickman2-Oct-08 18:33
Aaron Hickman2-Oct-08 18:33 
GeneralRe: Help with a WPF Combobox Pin
User 2710095-Oct-08 14:17
User 2710095-Oct-08 14:17 
GeneralRe: Help with a WPF Combobox Pin
ColinM1237-Oct-08 13:15
ColinM1237-Oct-08 13:15 
GeneralRe: Help with a WPF Combobox Pin
User 27100911-Oct-08 14:28
User 27100911-Oct-08 14:28 
AnswerSolution: Re: Help with a WPF Combobox Pin
User 27100911-Oct-08 16:53
User 27100911-Oct-08 16:53 
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/

<!-- Use this when data binding your items source-->
<ComboBox ItemsSource="{Binding}" Width="100" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

<!-- Use this when adding items in-line to your ComboBox-->
<ComboBox Width="100" VerticalAlignment="Center" SelectedIndex="0">
<ComboBox.Resources>
<Style TargetType="ComboBoxItem">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ComboBox.Resources>
<ComboBoxItem>Greetings from the planet known as Earth</ComboBoxItem>
<ComboBoxItem>Thanks to Josh Smith for this tip!</ComboBoxItem>
</ComboBox>

Cheers, Karl

&raquo; CodeProject 2008 MVP

My Blog | Mole's Home Page |
XAML Power Toys Home Page
Just a grain of sand on the worlds beaches.

-- modified 27-Feb-21 21:01pm.
GeneralRe: Solution: Re: Help with a WPF Combobox Pin
Aaron Hickman11-Oct-08 17:22
Aaron Hickman11-Oct-08 17:22 
GeneralRe: Solution: Re: Help with a WPF Combobox Pin
User 27100911-Oct-08 17:29
User 27100911-Oct-08 17:29 
QuestionAjax Tool Error Pin
gautamamit81-Oct-08 22:14
gautamamit81-Oct-08 22:14 
GeneralWrong forum Pin
Pete O'Hanlon1-Oct-08 23:13
mvePete O'Hanlon1-Oct-08 23:13 
AnswerRe: Ajax Tool Error Pin
Paul Conrad3-Oct-08 11:17
professionalPaul Conrad3-Oct-08 11:17 
QuestionWindowsFormsHost and keyboard focus Pin
Paul A. Howes1-Oct-08 4:15
Paul A. Howes1-Oct-08 4:15 
GeneralRe: WindowsFormsHost and keyboard focus Pin
Paul A. Howes1-Oct-08 4:32
Paul A. Howes1-Oct-08 4:32 
AnswerRe: WindowsFormsHost and keyboard focus Pin
Patrick Klug8-Oct-08 17:35
Patrick Klug8-Oct-08 17:35 
QuestionControl similar to new message control Pin
_iobuf30-Sep-08 7:03
_iobuf30-Sep-08 7:03 
AnswerRe: Control similar to new message control Pin
Paul Conrad6-Oct-08 18:52
professionalPaul Conrad6-Oct-08 18:52 
QuestionWPF Data binding Pin
koleraba27-Sep-08 8:21
koleraba27-Sep-08 8:21 
AnswerRe: WPF Data binding Pin
User 27100928-Sep-08 6:12
User 27100928-Sep-08 6:12 
GeneralRe: WPF Data binding Pin
koleraba29-Sep-08 6:01
koleraba29-Sep-08 6:01 
QuestionSimple Textbox validation Pin
Aslesh26-Sep-08 5:27
Aslesh26-Sep-08 5:27 
AnswerRe: Simple Textbox validation Pin
Pete O'Hanlon26-Sep-08 8:18
mvePete O'Hanlon26-Sep-08 8:18 
GeneralRe: Simple Textbox validation Pin
Aslesh26-Sep-08 9:57
Aslesh26-Sep-08 9:57 
GeneralRe: Simple Textbox validation Pin
Pete O'Hanlon26-Sep-08 10:14
mvePete O'Hanlon26-Sep-08 10:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.