Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Phone 7 Dynamic ListBox Template
    primarykey
    data
    text
    <p>I've just recently started working on an app that displays a bunch of xml data in a listBox, but the problem is not every xml item has a child value (In my problem, upload), so its listBox code shouldn't be displayed.</p> <p>Example:</p> <pre><code>&lt;item&gt; &lt;id&gt;1&lt;/id&gt; &lt;body&gt;Some text&lt;/body&gt; &lt;upload&gt;&lt;/upload&gt; &lt;created&gt;Some text&lt;/created&gt; &lt;/item&gt; </code></pre> <p>I'm getting the data and populating my list this way:</p> <pre><code>var data = from query in loadedData.Descendants("item") select new droppedItem { Id = (int)query.Element("id"), Body = (string)query.Element("body"), Upload = (string)query.Element("upload"), Created = (DateTime)ConvertFromUnixTimestamp((double)query.Element("created")) }; userDrops.ItemsSource = data; </code></pre> <p>And my xaml looks like:</p> <pre><code>&lt;ListBox Margin="0,0,-12,0" Name="userDrops"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Margin="0,0,0,17" Width="432"&gt; &lt;RichTextBox&gt; &lt;Paragraph&gt; &lt;Run Text="{Binding Body}" FontSize="25" FontFamily="Segoe WP"&gt;&lt;/Run&gt; &lt;/Paragraph&gt; &lt;Paragraph&gt; &lt;Hyperlink NavigateUri="{Binding Upload}" TargetName="_blank" FontSize="25" FontFamily="Segoe WP"&gt;{Binding Upload}&lt;/Hyperlink&gt; &lt;/Paragraph&gt; &lt;Paragraph&gt; &lt;Run Text="{Binding Created}" FontFamily="Segoe WP SemiLight"&gt;&lt;/Run&gt; &lt;/Paragraph&gt; &lt;/RichTextBox&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>What I want to do is only display the paragraph holding the upload info if the xml upload child holds a value. Otherwise, just remove it from the listBox. I can't figure out how to change the basic listBox template though.</p> <p>Any help would be great!</p>
    singulars
    1. This table or related slice is empty.
    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. 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