This is a migrated thread and some comments may be shown as answers.

LocationBox question

1 Answer 65 Views
Map
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 24 Feb 2010, 07:56 PM
I am trying to bind the location box in the RADMAP demo to a web service call, I'm getting this error "A value of type 'Location' cannot be added to a collection or dictionary of type 'UIElementCollection'."

Here is the XAML, I get a blue squiggly line under it and it fails when I run it.

<ListBox x:Name="LocationBox" SelectionChanged="LocationBox_SelectionChanged" ItemContainerStyle="{StaticResource lv-ListBoxItem}" Background="Transparent" BorderBrush="Transparent">  
 
                <ListBox.ItemTemplate> 
                    <DataTemplate> 
 
                       <StackPanel Orientation="Vertical">  
 
                              
                            <mapNamespace:Location Description="{Binding RepName}"  Latitude="{Binding Latitude}" Longitude="{Binding Longitude}"/>  
                              
 
                        </StackPanel> 
 
                    </DataTemplate> 
                </ListBox.ItemTemplate> 
            </ListBox> 

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 01 Mar 2010, 01:05 PM
Hi Sam,

You cannot use the Location class inside a DataTemplate as it is not a visual UIElement (as the error correctly suggests). You can set a collection of Location objects as ItemsSource but then you need to either set the ListBox.DisplayMemberPath property or you need to specify a valid DataTemplate (one that contains UIElements).

Also, for general Silverlight questions that are not related to the RadControls suite, you can try the official MS Silverlight forums as well.


Best wishes,
Manuel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Map
Asked by
Sam
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or