我有个情况。我在Silverlight导航应用程序中创建Listbox,作为数据板,我在HyperlinkButton中使用了Grid。
我需要同时选择ListBox.CurrentItem、和来通过HyperlinkButton导航。
问题是它只导航而不选择项。
我在用MVVM。
发布于 2010-11-11 18:51:35
嗯,您应该能够通过DataContext将HyperlinkButton的CommandParameter={Binding }传递给它的命令。然后,您应该能够设置视图模型中绑定到列表框的SelectedItem属性的任何属性。
有点像
<HyperlinkButton Command="{Binding ElementName=ListBoxName, Path=DataContext.linkClickedCommand}" CommandParameter={Binding }/>
private void ExeucteLinkClickedCommand(object parameter)
{
this.SelectedItem = (ItemType)parameter;
}https://stackoverflow.com/questions/4157909
复制相似问题