【发布时间】:2011-12-22 15:37:20
【问题描述】:
My ListBox.SelectedValue 返回第一个选定项,而不是当前选定项。 (当前选中的项目意味着除了选中的ITEMS之外,我还显示了最后一个选中的项目)
这次我的 SelectionMode 是 Multiple 而不是 Single。
private void ListBoxSource_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var fileSelected = (FileFound)this.ListBoxSource.SelectedValue;
BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit();
bmpImage.UriSource = new Uri(fileSelected.FileFullName, UriKind.Absolute);
bmpImage.EndInit();
Image1.Source = bmpImage;
}
现在,我没有在事件中执行此操作,而是尝试将我的 Image 控件绑定到 ListBoxSource 但是没有显示任何内容。
Source="{Binding ElementName=ListBoxSource, Path=SelectedItems
有机会绑定吗?或者我的 SelectionChangedEvent 代码有什么问题?
【问题讨论】:
-
我理解对了吗,您已经选择了多个项目,然后您又选择了一个项目,并且您想获得对最后一个选定项目的引用?
-
@StaWho 正是...因为我已经有其他列表框显示所有选定的项目。我只想显示最后选择的项目。
标签: c# .net wpf silverlight