Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two list boxes related to each other on the same form. The first is bound to a IEnumberable of MembershipDataViewModel Objects (Essentially Users). I have a fancy Data Template that shows the user, email and whether or not it has been modified and all, it works great. However, i have a second list box that is bound to an IEnumerable of RoleDataViewModel objects, this binding is working fine, however, the binding of SelectedItems to the SelectedUser of the first Listbox is not working. Here is a summary.

UserListBox -----
ItemsSource = {Binding AllUsers} (property of view model, IEnumerable<membershipdataviewmodel>)
SelectedItem = {Binding SelectedUser} (property of view model, MembershipDataViewModel)
XML
<Intersoft:UXListBox Grid.Row="1" SelectionMode="Single" Width="200" ItemsSource="{Binding Users}" SelectedItem="{Binding SelectedUser, Mode=TwoWay}" VerticalAlignment="Stretch">
    <Intersoft:UXListBox.ItemTemplate>
        <DataTemplate>
            <Border BorderBrush="DarkGray" BorderThickness="1" Width="190">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="20" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="23" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Grid.ColumnSpan="2" FontFamily="Verdana" FontSize="14" VerticalAlignment="Bottom" Text="{Binding Username}" HorizontalAlignment="Stretch"/>
                    <!--                                        <TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Text="*" FontSize="16" FontFamily="Verdana" Foreground="Red" FontWeight="Bold" Visibility="{Binding HasChanges, Converter={StaticResource BooleanVisibilityValueConverter}}" /> -->
                    <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Bottom" FontFamily="Verdana" FontSize="10" Foreground="MediumSlateBlue" Text="{Binding Email}" />
                </Grid>
            </Border>
        </DataTemplate>
    </Intersoft:UXListBox.ItemTemplate>
</Intersoft:UXListBox>



RoleListBox -----
SelectionMode = "Multiple"
ItemsSource = {Binding AllRoles} (property of view model, IEnumerable<roledataviewmodel>)
DisplayMemberPath= "RoleName" (this works, the correct property is read for display, type of this property is string)
SelectedValuePath = "RoleName" (This does not appear to be working as no selected items are ever present regardless of binding below)
SelectedItems = {Binding SelectedUser.Roles} (sub-property of property of view model, the type is ObservableCollection<string>)
XML
<Intersoft:UXListBox  x:Name="roleInfoUXListBox" SelectionMode="Multiple" ItemsSource="{Binding Roles}" SelectedItems="{Binding SelectedUser.Roles, Mode=TwoWay}" Height="100" Width="150" ItemContainerStyle="{StaticResource UXListBoxItemStyle1}" />


I cannot seem to get the selected items to ever populate. Can anyone help me figure out what I am missing here?
Posted
Comments
VysakhMenon 18-May-11 1:42am    
Post your view model too

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900