Layer datatemplate and item binding.

5 posts, 0 answers
  1. Clint Singer
    Clint Singer avatar
    133 posts
    Member since:
    Oct 2012

    Posted 19 Nov 2009 Link to this post

    Hi,

    I am trying to use the InformationLayer by binding ItemsSource to an object collection and using ItemTemplateSelector to pick the template that is used.  When I run my program I get the following error:

    ItemsControl.Items must be a derivative of type UIElement.

    I looked through the examples and noticed that you are using ControlTemplates in the the DynamicLayer sample.  Is there something I need to do to use binding to regular objects and their corresponding data templates?

    Cheers,
    Clint
  2. Clint Singer
    Clint Singer avatar
    133 posts
    Member since:
    Oct 2012

    Posted 19 Nov 2009 Link to this post

    I have also tried creating my own MapLayer derived class and perhaps I can get some help with the ItemsControl and PrepareContainerForItemOverride usage.

    Obviously the Items property is currently filled with non UIElement derived objects which means that I need to change it to something that can be drawn.  I understand this is usually means that the object is wrapped by a container object.  I also noticed that PrepareContainerForItem override is called by something in the base class but I am unable to figure out how to get access to it from within the ArrangeOverride.

    If I call base.ArrangeOverride the objects will take my data template and line themselves vertically as if they were in a list box.  Obviously something in the base class is correctly using the datatemplates and then rendering it to the screen.  That is the behavior I am trying to override.

    Please help!

    Cheers,
    Clint
  3. Clint Singer
    Clint Singer avatar
    133 posts
    Member since:
    Oct 2012

    Posted 19 Nov 2009 Link to this post

    I have now moved a bit further after hunting high and low and then finally finding ItemContainerGenerator.ContainerFromItem(item).  Now that I have the container object, I am still at a loss as to how to get the location attached property that should be attached in the DataTemplate as well as how to actually do the layout of the container item itself.  I tried Canvas.SetTop/Left on the container object but that didn't work.

    Since I don't know my geo graphic position I tried the Canvas.SetTop/Left with just a hard coded value of 300 so I don't know if that is even valid.  Perhaps it should be between 0 and 1 since the map is MultiScaleImage?

    Cheers,
    Clint
  4. Clint Singer
    Clint Singer avatar
    133 posts
    Member since:
    Oct 2012

    Posted 19 Nov 2009 Link to this post

    A littler further along now...

    I ended up calling the Arrange method on the container item (which in this case is a ContentPresenter) and I am able to arrange it to physical screen coordinates.  Now all I need to figure out is why my attached property won't work and then how to convert that geographic position to an appropriate screen location.

    Of course, the original problem of not being able to data bind to a data collection is still in effect, because then I wouldn't have to create my own layer class.  (Though it has been an interesting experience.)

    Cheers,
    Clint
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 25 Nov 2009 Link to this post

    Hi Clint,

    The instance of the Location class has the GetPoint method.
    You can use it to getting the screen point on the RadMap control according to its latitude-longitude coordinates.

    Best wishes,
    Andrey Murzov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top