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

Layer datatemplate and item binding.

4 Answers 109 Views
Map
This is a migrated thread and some comments may be shown as answers.
Clint Singer
Top achievements
Rank 1
Clint Singer asked on 19 Nov 2009, 09:22 PM
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

4 Answers, 1 is accepted

Sort by
0
Clint Singer
Top achievements
Rank 1
answered on 19 Nov 2009, 11:06 PM
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
0
Clint Singer
Top achievements
Rank 1
answered on 20 Nov 2009, 01:18 AM
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
0
Clint Singer
Top achievements
Rank 1
answered on 20 Nov 2009, 01:36 AM
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
0
Andrey
Telerik team
answered on 25 Nov 2009, 10:03 AM
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.
Tags
Map
Asked by
Clint Singer
Top achievements
Rank 1
Answers by
Clint Singer
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or