Hi I have a WPF Combobox which shows a list of Enums. Code is below.
<ComboBox HorizontalAlignment="Left" Margin="139,299,0,0" VerticalAlignment="Top" ItemsSource="{Binding Source={StaticResource Enum}}" Width="78"/>
However, when the view is loaded, it shows the first enum in the list, but I would like it to show 'Please Select', so is there XAML to do this (C# in the view if needs be..)
Thanks
All good answers that has been supplied, but I used the following to solve my problem
<ComboBox SelectedIndex="0"> <ComboBox.ItemsSource> <CompositeCollection> <ListBoxItem>Please Select</ListBoxItem> <CollectionContainer Collection="{Binding Source={StaticResource YOURDATASOURCE}}" /> </CompositeCollection> </ComboBox.ItemsSource> </ComboBox>
Thanks for everyone who has helped!
Add these properties to your combobox and you can set a default 'Please Select' Text on a combobox.
<ComboBox IsEditable="True" IsReadOnly="True" Text="Please Select"/>
For a more versatile solution you can create a watermark for the combobox
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With