如何通过点击绑定图像从另一个绑定图像源路径获取图像源路径
问题描述:
我已经绑定了一个图像在一个列表框中,当我点击一个绑定图像时,将根据源图像设置绑定图像资源。如何通过点击绑定图像从另一个绑定图像源路径获取图像源路径
这是我想从绑定数据中显示图像的代码。
<Grid x:Name="Icon" Margin="134,51,173,556">
<Image x:Name="MyIconImage" HorizontalAlignment="Left" Height="90" Width="93" Source="" />
</Grid>
下面是代码,我已经绑定数据
<Grid Margin="0,366,0,0">
<ListBox x:Name="List"
ItemsSource="{Binding ListItemSource}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image x:Name="IconListImage" Source="{Binding IconPath}" Width="48" Height="48" Tap="IconListImage_Tap"/>
<TextBlock x:Name="appName" Text="{Binding AppName}"/>
<TextBlock Text="{Binding IconPath}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
答
你尝试SelectedValuePath?
<Image x:Name="MyIconImage" HorizontalAlignment="Left" Height="90" Width="93" Source="{Binding ElementName=List, Path=SelectedValue}" />
<ListBox x:Name="List" ItemsSource="{Binding ListItemSource}" SelectedValuePath="IconPath">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image x:Name="IconListImage" Source="{Binding IconPath}" Width="48" Height="48" Tap="IconListImage_Tap"/>
<TextBlock x:Name="appName" Text="{Binding AppName}"/>
<TextBlock Text="{Binding IconPath}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
是的我试过了,但没有工作.. – 2014-09-25 05:10:49