开发者

CurrentItem vs Hyperlink

开发者 https://www.devze.com 2023-01-24 09:27 出处:网络
I have a situtation. Im creating Listbox in Silverlight Navigation App and as datatemplate i have Grid with HyperlinkButton.

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号