I am still new to MVVM
(and C#) so please let me know if my question is unclear and I will update/clarify.
I have a ListView
in my xaml
with the following code:
<ListView.Resources>
<local:IndexConverter x:Key="IndexConverter" />
<DataTemplate x:Key="OrdinalColumnDataTemplate">
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListViewItem},
Converter={StaticResource ResourceKey=IndexConverter}}" HorizontalAlignment="Right" />
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView x:Name="gridView3">
<GridViewColumn Header="#" CellTemplate="{StaticResource ResourceKey=OrdinalColumnDataTemplate}" />
<GridViewColumn DisplayMemberBinding="{Binding Name, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}" Header="Name" />
<GridViewColumn DisplayMemberBinding="{Binding License, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}" Header="License" />
</GridView>
</ListView.View>
It works as expected, It is populated with Name
and License
attributes of each element.
Now I would like to add a ComboBox
and populate it with the unique Names
of the same element which are shown in the ListView
.
QUESTION 1: I have tested the below code but it does not work, how should the xml look like?
<ComboBox Name="filterUserComboBox" ItemsSource="{Binding Path=licenseListView, ElementName=Name}"></ComboBox>
QUESTION 2: When the above works properly, how do I add an 'all' (or a single empty element) element to the ComboBox?