-1

我的一个网格单元中有一个带有超链接的列表框。当我单击列表框中的任何项目时,当前项目始终是列表框中的第一条记录,并且所选项目始终为空。这是我的WPF。我究竟做错了什么?

 <DataTemplate x:Key="CellTemplate.InputManagersList">
        <StackPanel Orientation="Horizontal">
            <ListBox ItemsSource="{Binding Path=InputManagers}" HorizontalAlignment="Left">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock>                                    
                        <Hyperlink Name="inputManagerName" 
                           Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.OpenInputManagerViewCommand}"
                           CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}}">
                           <TextBlock Text="{Binding Path=Name}" />
                        </Hyperlink>
                    </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <ListBox.Style>
                    <Style TargetType="ListBox">
                        <Setter Property="HorizontalAlignment" Value="Left"/>
                        <Setter Property="BorderThickness" Value="0"/>
                    </Style>
                </ListBox.Style>
            </ListBox>
        </StackPanel>
    </DataTemplate>
4

1 回答 1

0

SelectedItem="{Binding SelectedName}"在列表视图对象中绑定。

于 2012-06-04T13:56:00.337 回答