Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the <code>Tag</code> parameter. Note that the <code>{Binding}</code> binds the entire object itself.</p> <p>For example,</p> <pre><code>class Myobj { string param1 { get; set; } string param2 { get; set; } } ObservableCollection&lt;Myobj&gt; collection; </code></pre> <p>If collection is your ItemsSource, then inside your DataTemplate , a {Binding} refers to an entire instance of Myobj.</p> <pre><code>&lt;HyperlinkButton Content="Comments" Click="HyperlinkButton_Click" FontSize="15" x:Name="commentsLink" Tag="{Binding}" /&gt; </code></pre> <p>then in your Click Event, simply cast sender to a hyperlink button, and get the Tag.</p> <pre><code>... var hb = sender as HyperLinkButton; if (hb != null) { var obj = hb.Tag as Myobj; if (obj != null) { } } ... </code></pre> <p>Check out this cheatsheet on binding. It's very helpful.</p> <p><a href="http://www.nbdtech.com/Free/WpfBinding.pdf" rel="nofollow">http://www.nbdtech.com/Free/WpfBinding.pdf</a></p> <p>Note that this implementation does not use <code>SelectedIndex</code> - but it doesn't need to. Since the <code>HyperLinkButton</code> has a reference to the object that you are generating the <code>ListBoxItem</code> for, there's no need for it. </p> <p>Finally, here's a sample project</p> <p><a href="https://skydrive.live.com/redir.aspx?cid=ef08824b672fb5d8&amp;resid=EF08824B672FB5D8!352&amp;parid=EF08824B672FB5D8!343" rel="nofollow">https://skydrive.live.com/redir.aspx?cid=ef08824b672fb5d8&amp;resid=EF08824B672FB5D8!352&amp;parid=EF08824B672FB5D8!343</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload