Xaml 在另一个列表框中绑定SelectedItem

Xaml 在另一个列表框中绑定SelectedItem,xaml,mvvm,windows-phone,bind,selecteditem,Xaml,Mvvm,Windows Phone,Bind,Selecteditem,我正在尝试绑定SelectedItem,它位于另一个列表框中,但我从输出中得到此绑定错误: System.Windows.Data Error: BindingExpression path error: 'Time' property not found on '[23, System.Collections.Generic.List`1[MarsrutaiAPI.ArrivalTime]]' 'System.Collections.Generic.KeyValuePair`2[System.

我正在尝试绑定SelectedItem,它位于另一个列表框中,但我从输出中得到此绑定错误:

System.Windows.Data Error: BindingExpression path error: 'Time' property not found on '[23, System.Collections.Generic.List`1[MarsrutaiAPI.ArrivalTime]]' 'System.Collections.Generic.KeyValuePair`2[System.Int32,System.Collections.Generic.List`1[MarsrutaiAPI.ArrivalTime]]' (HashCode=1268928309). BindingExpression: Path='Time' DataItem='[23, System.Collections.Generic.List`1[MarsrutaiAPI.ArrivalTime]]' (HashCode=1268928309); target element is 'System.Windows.Controls.ListBox' (Name='innerList'); target property is 'SelectedItem' (type 'System.Object')..
嵌套的列表框声明为:

<ListBox ItemsSource="{Binding TimeTable}" Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityNegativeConverter}}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="70"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="{Binding Key}" Style="{StaticResource NormalText}" FontSize="42" Margin="0,0,10,0" HorizontalAlignment="Center" />
                        <ListBox Grid.Column="1" Name="innerList" ItemsSource="{Binding Value}" SelectedItem="{Binding Time,Mode=TwoWay}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                            <ListBoxItem Margin="0,0,5,5"/>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <toolkit:WrapPanel Orientation="Horizontal"/>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Border BorderBrush="{StaticResource tekstas}" BorderThickness="1" CornerRadius="5" Margin="5" Background="{Binding IsAccessible,Converter={StaticResource IsAccessibleToColor}}">
                                        <TextBlock Style="{StaticResource NormalText}" Text="{Binding ExpectedTime, StringFormat=\{0:mm\}}" Margin="10" HorizontalAlignment="Center"/>
                                    </Border>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <Border Grid.Row="1" Grid.ColumnSpan="2" Margin="10"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
谢谢你的帮助:)

试试这个:

SelectedItem="{Binding Path=Time, RelativeSource={RelativeSource AncestorType={x:Type Grid}}}"
如果不可能使用RelativeSource,则将父容器命名为以下网格

<Grid Name="gridFoo" Tag={Binding} />



很遗憾,这是Windows phone,因此我认为不支持AncestorType,也谢谢!那一个奏效了,我自己永远也想不到:)
<Grid Name="gridFoo" Tag={Binding} />
<ListBox Grid.Column="1" Name="innerList" ItemsSource="{Binding Value}" SelectedItem="{Binding Tag.Time, ElementName=gridFoo}" ScrollViewer.VerticalScrollBarVisibility="Disabled">