0

同じデータ ソースを ListBox ItemsSource とその Listbox Item Template にバインドするにはどうすればよいですか。

<ListBox ItemsSource="{Binding TrackPluginView }"  BorderBrush="Transparent"  Height="180" ScrollViewer.VerticalScrollBarVisibility="Auto"
     Grid.IsSharedSizeScope="True"
     HorizontalContentAlignment="Stretch">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <ContentControl Width="auto" Height="auto" Content="{ Binding TrackPluginView}" />
                            <Button Command="{Binding}" Content="Delete" Width="150" HorizontalAlignment="Right" VerticalAlignment="Center" ></Button>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
4

1 に答える 1

0
    <ListBox ItemsSource="{Binding TrackPluginView }"  BorderBrush="Transparent"  Height="180" ScrollViewer.VerticalScrollBarVisibility="Auto"
 Grid.IsSharedSizeScope="True"
 HorizontalContentAlignment="Stretch">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Vertical">
                    <ContentControl Width="auto" Height="auto" Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, Path=DataContext.TrackPluginView}" />
                    <Button Command="{Binding}" Content="Delete" Width="150" HorizontalAlignment="Right" VerticalAlignment="Center" ></Button>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
于 2013-10-30T07:42:38.693 に答える