日期:2014-05-17  浏览次数:20825 次

ListView绑定了一个List<>集合,有没有方法找到集合某一项对应的ListViewItem中的控件
可能表达的不清楚用,结合一下代码应该清楚点。

如果我想找UserList[3]对应ListView列表中的<Grid MouseLeftButtonDown="RestAuthCode" 这个元素的话应该如何找?还有如果我在ListView中单击了某行的按钮,如何查的该行对应的UserList是集合中的哪一个?求助高人解答,谢谢

xaml:
<ListView Margin="0,10,0,0" Grid.Row="1" ItemsSource="{Binding Path=UserList}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Vertical" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="8" Orientation="Horizontal">
                            <StackPanel>
                                <TextBlock Margin="0,31,0,9" Foreground="#ffbbbbbb" Text="{Binding Path=UserName,Mode=OneTime}" Width="120" />
                                <CheckBox HorizontalAlignment="Center" Content="xxx" IsChecked="True" />
                            </StackPanel>
                            <StackPanel>
                                <ComboBox Margin="8,28,8,5" Height="23" Width="90" Text="{Binding Path=BuyVersion,Mode=OneWayToSource}">
                                </ComboBox>
                                <CheckBox HorizontalAlignment="Center" Content="bbb" IsChecked="True" />
                            </StackPanel>
          &