Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It sounds like you're trying to do this from a WinForms / CF.Net style approach. Whilst you can probably do this I'd recommend against it as you're really not getting the value of Silverlight. Let's presume that your <code>Tips</code> class looks something like;</p> <pre><code>public class Tip { public int Id { get; set; } public string Title { get; set; } public string Restaurant { get; set; } } </code></pre> <p>You can then bind a list of these to a <code>ListBox</code>;</p> <pre><code>listBoxTipHistory.ItemsSource = get_Tips() </code></pre> <p>Your <code>XAML</code> is used to describe how these items are displayed;</p> <pre><code>&lt;ListBox x:Name="listBoxTipHistory"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Title}" /&gt; &lt;TextBlock Text="{Binding Restaurant}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>The <code>SelectedItem</code> on the <code>ListBox</code> will be the currently selected <code>Tip</code> (as an <code>object</code>), not the actual <code>ListBoxItem</code> that's selected. So to get the ID of the selected <code>Tip</code>;</p> <pre><code>Tip selectedTip = listBoxTipHistory.SelectedItem as Tip; if (selectedTip != null) { Console.WriteLine("The selected Tip is {0}", selectedTip.Id); } </code></pre> <p>A further suggestion would be for you to look into the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" rel="nofollow" title="INotifyPropertyChanged">INotifyPropertyChanged</a> interface which will allow changes to your model to automatically get updated in the UI</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.
    3. 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