views:

2190

answers:

1

Hello,

I've following ListView Item (in a WPF Form):

   <ListView Name="listViewTeam" ItemsSource="{Binding Path=TeamList}">
        <ListView.View>
            <GridView  ColumnHeaderTemplate ="{StaticResource BlueHeader}">
                <GridView.ColumnHeaderContainerStyle>
                    <Style TargetType="{x:Type GridViewColumnHeader}">
                        <Setter Property="HorizontalContentAlignment" Value="Left" />
                    </Style>
                </GridView.ColumnHeaderContainerStyle>
                <GridViewColumn Width="34"  Header="Nr" DisplayMemberBinding="{Binding Path=TeamNr , Mode=OneWay}"/>
                <GridViewColumn Header="Team" DisplayMemberBinding="{Binding Path=TeamName, Mode=OneWay}"/>
            </GridView>
        </ListView.View>
    </ListView>

DataContext is a TeamViewModel, which contains
a) a List of Teams
b) a SelectedTeam Property (which is a Team-Object and contains Team.TeamName and Team.TeamNr )

Loading of the TeamViewModel.TeamListe into the ListView works fine (I get all Team-Objects from the list displayed in my ListView)

How can I set the TeamViewModel.SelectedTeam Property to the Row-Value, which is selected?

Thanks!

Cheers

+1  A: 

Set the ListView's SelectedItem property to {Binding Path=SelectedTeam}

marklam
easy if you know how to ... thanks man!
JohnIdol