私の質問(タイトル)に関しては、選択したアイテムをlistBoxからuniformGridにバインドできます。 しかし、すでに多くのアイテムを選択していても、 UniformGridには 1 つのアイテムしか表示されません。
これを行う方法を教えてください。
または 、選択した ListBox 項目で UniformGrid を埋めることは可能ですか?
または 、リストボックスから選択したアイテムを転送 (バインド) して表示する他のオプションは何ですか?
または 、同様の例がある場合は、コードを見ていきます。
正確には、私の ListBox アイテムは画像ですが、画像のみである必要はありません。選択した項目を Grid または ListBox で選択した項目を表示するものにバインドする方法を知りたいだけです。
ありがとうございました
XAML:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="SampleBinding.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Window.Resources>
<DataTemplate x:Key="ItemTemplate">
<StackPanel>
<Image Source="{Binding myImages}" HorizontalAlignment="Left" Height="64" Width="64"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
<ListBox x:Name="listBox" HorizontalAlignment="Left" ItemTemplate="{DynamicResource ItemTemplate}" ItemsSource="{Binding Collection}" Margin="19,40,0,102" Width="200" SelectionMode="Multiple"/>
<UniformGrid x:Name="uGrid" DataContext="{Binding SelectedItem, ElementName=listBox}" Margin="273,40,78,132" d:DataContext="{Binding Collection[0]}" Grid.Row="2" Grid.Column="2">
<Image x:Name="imageItem" Source="{Binding myImages}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="100"/>
</UniformGrid>
</Grid>