我正在一個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