我正在一个WPF应用程序有一个ListView与几个图像源加载到它。如何绑定选定的图像,以便将其显示在网格中包含的较大查看区域中?绑定ListView SelectedItem
在此先感谢!
这里是我一起工作的代码:
<Window x:Class="ListViewImageSelection.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="300" Width="400">
<Window.Resources>
<BitmapImage x:Key="bike" UriSource="Images/bike.bmp"/>
<BitmapImage x:Key="car" UriSource="Images/car.bmp"/>
<BitmapImage x:Key="flower" UriSource="Images/flower.bmp"/>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<ListView Name="MyListView" Grid.Column="1" VerticalAlignment="bottom" HorizontalAlignment="Center" ScrollViewer.PanningMode="VerticalOnly">
<Image Source="{StaticResource bike}" Width="110" />
<Image Source="{StaticResource car}" Width="110" />
<Image Source="{StaticResource flower}" Width="110" />
</ListView>
<Image Grid.Column="0" Stretch="Uniform" Source="{Binding ElementName=MyListView, Path=SelectedItem.ImageUri}"/>
</Grid>
@Joe我想你的建议,但不能让它开始工作。我发布了我的代码,你可以看一下吗? – ScanMan