I have a situtation. Im creating Listbox in Silverlight Navigation App and as datatemplate i have Grid with HyperlinkButton.
I need to select ListBox.CurrentItem AND to Navigate by HyperlinkButton the same time.
Probl开发者_开发问答em is that it only navigates but not selects item.
P.S. Im using MVVM.
Hm, you should be able to pass the DataContext
of the HyperlinkButton
to it's command via CommandParameter={Binding }
. You then should be able to set whatever property on your viewmodel that is bound to the SelectedItem
property of the listbox.
Something Like
<HyperlinkButton Command="{Binding ElementName=ListBoxName, Path=DataContext.linkClickedCommand}" CommandParameter={Binding }/>
private void ExeucteLinkClickedCommand(object parameter)
{
this.SelectedItem = (ItemType)parameter;
}
精彩评论