Information Layer : multiple items

4 posts, 0 answers
  1. Charles
    Charles avatar
    5 posts
    Member since:
    Feb 2015

    Posted 01 Mar Link to this post

    I need to draw an image at the position on the map, and it must move as the position moves.  I also needto draw a different image on some static locations.  This data comes from a collection of locations.

    I have coded this as such(below)... but it does not run.  I get the error: "Items collection must be empty before using ItemsSource."

    When i remove the waypoints, the current position works, and when i remove the current position, the waypoints works.  I assume there is something very simple i am missing or not organizing correctly.

    <telerik:InformationLayer ItemsSource="{Binding Path=Waypoints}" ItemTemplate="{StaticResource Rectangle}">
        <telerik:MapPinPoint telerik:MapLayer.Location="{Binding CurrentPosition}" ImageSource="icon.png" />
    </telerik:InformationLayer>

  2. Charles
    Charles avatar
    5 posts
    Member since:
    Feb 2015

    Posted 01 Mar Link to this post

    OK this was very simple... MULTIPLE INFORMATION LAYERS ARE VALID... below is the code just in case someone wants it

    <telerik:InformationLayer x:Name="InformationLayer" ItemTemplate="{StaticResource Rectangle}" />
    <telerik:InformationLayer>
        <telerik:MapPinPoint telerik:MapLayer.Location="{Binding State.CurrentPosition}"
                         ImageSource="icon.png"
        </telerik:MapPinPoint>
    </telerik:InformationLayer>

     

     

  3. UI for WPF is Visual Studio 2017 Ready
  4. Charles
    Charles avatar
    5 posts
    Member since:
    Feb 2015

    Posted 01 Mar in reply to Charles Link to this post

    also, the first IL ItemsSource is now set in codebehind once the control is loaded.     
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 03 Mar Link to this post

    Hi Charles,

    The InformationLayer is typical ItemsControl and the error you received is expected - you cannot use both Items and ItemsSource properties at the same time. You have to either use databinding (ItemsSource) or populate the items manually (via the Items property, when you set the PinPoint in xaml you are directly popualting the Items property).

    Your solution is to create two separate layers, however, this could also be achieved by using ItemTemplateSelector - you will be able to select different ItemTemplates based on the type of the business object. You can check examples here.

    Regards,
    Petar Mladenov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top