TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Roberto Salemi
NA
146
141.1k
[WPF] ComboBox and ItemSource: add one empty row
Feb 27 2015 6:26 AM
Hi,
I have a ComboBox, defined as:
<ComboBox Name="cmbTypeOfSchedule"
DataContext="{StaticResource DomainDataViewModel}"
ItemsSource="{Binding SchedTypes}"
DisplayMemberPath="Description"
Width="120">
I would insert, in head, an empty item or empty called "Select all".
So:
1) I defined a StaticResource:
<CollectionViewSource x:Key="SchedTypesWithEmptyItem" Source="{Binding SchedTypes}" />
2) Edit my Combobox as:
<ComboBox Name="cmbTypeOfSchedule"
DataContext="{StaticResource DomainDataViewModel}"
DisplayMemberPath="Description"
Width="120">
<ComboBox.ItemsSource>
<CompositeCollection>
<ComboBoxItem Content="Select all" />
<CollectionContainer Collection="{Binding Source={StaticResource SchedTypesWithEmptyItem}}" />
</CompositeCollection>
</ComboBox.ItemsSource>
The problem: in the ComboBox I see only "Select all" and not other item from my Collection and when I select "Select all", it does not stay selected.
Thanks.
Reply
Answers (
1
)
[WPF] ComboBox: error multiConverter and Selected Item
Using an online source to set the text of a textblock