Note that there are some explanatory texts on larger screens.

plurals
  1. POXAML ListBox Binding
    primarykey
    data
    text
    <p>I'm working on a GIS website in C# and Silverlight, and I'm trying to populate a ListBox based on map layers. The code works if I lump everything together in a single XAML file (where the Map is defined in the same file), but I am trying to separate things into separate classes, and the ListBox will not populate in the other class.</p> <p>XAML Code..</p> <p> </p> <pre><code> &lt;CheckBox IsChecked="{Binding Visible, Mode=TwoWay}" /&gt; &lt;Slider Margin="-5,0,0,0" Minimum="0" Maximum="1" Width="30" Value="{Binding Opacity, Mode=TwoWay}" Height="18" /&gt;--&gt; &lt;TextBlock Text="{Binding ID, Mode=OneWay}" Margin="5,0,0,0" &gt; &lt;ToolTipService.ToolTip&gt; &lt;StackPanel MaxWidth="400"&gt; &lt;TextBlock FontWeight="Bold" Text="{Binding CopyrightText}" TextWrapping="Wrap" /&gt; &lt;TextBlock Text="{Binding Description}" TextWrapping="Wrap" /&gt; &lt;/StackPanel&gt; &lt;/ToolTipService.ToolTip&gt; &lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; </code></pre> <p> </p> <p>myMap is being set when the class is called by this C# code...</p> <p>public partial class TableOfContents : UserControl { Map myMap;</p> <pre><code>public TableOfContents(ref Map map) { InitializeComponent(); myMap = map; foreach (Layer thisLayer in myMap.Layers) { layerList.Items.Add(new TextBlock() { Text = thisLayer.ID }); } } </code></pre> <p>}</p> <p>The foreach statement adds TextBlocks for all of the map layers (this is just test code), so I know the information is being passed correctly, but the data binding defined in XAML doesn't seem to work.</p> <p>Any thoughts?</p> <p>EDIT: The XAML Code seems to be clipped in the post (although it's visible when I edit it). The data binding is defined by: ItemsSource="{Binding Path=Layers, ElementName=myMap}</p>
    singulars
    1. This table or related slice is empty.
    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.
    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