私の質問(タイトル)に関しては、私のリストボックスから選択した項目を既にuniformGridにバインドできます。 BUTすでに多くのアイテムを選択していても、UniformGridは1アイテムしか表示しません。ListBoxで選択した項目(SelectionMode = Multiple)からDataGridまたはUniformGridにデータをバインドする方法(SelectionMode = Multiple)
どうすればいいですか?
または ListBoxアイテムを選択してUniformGridを塗りつぶすことは可能ですか?
または リストボックスから選択したアイテムを転送(バインド)して表示する他のオプションは何ですか?
または 似たような例がある場合は、コードを参照してください。
正確には、私のリストボックスのアイテムはですが、画像BUTは画像のみである必要はありません。選択したアイテムをグリッドにバインドする方法や、リストボックスで選択したアイテムを表示する方法を知りたいだけです。
はサンキュー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>
私はあなたが常に1であるのListBoxのSelectedItemにグリッドのDataContextをバインドしていることがわかり
私はMVVMのアプローチについて多くの知識を持っていません。私は、C#とXAMLの基本的な知識しか持っていません。 **私の問題でObservableCollectionベースを使用したコード例をいくつか見せてもらえますか?**表現のブレンドを使用していますが、バインドには向いていませんが、 – Raf