I have looked through all of the samples, including the samples on this forum and I am just not understanding how to bind a collection of custom push pins using the MVVM paradigm. I understand the InformationLayer is an items control, so I should be able to bind anything to it, but it's just not working for me.
Consider a simple class like the following:
I'd like to be able to add a pin to the map for each Address. My intent is to eventually provide hover functionality so that a popup displays information over the pin when the mouse hovers over it, but I haven't gotten the pins to display. In the view model, I have a property of type ObservableCollection<Address>. I then bind to the address collection in the XAML with the following:
I understand I will have to create an item template in order to achieve the hover affect I'm looking for, but it is my understanding the above code should render pins for each location specified by an Address object. The following is an ICommand that handles the DragDropManager's OnDropInfo event (I'm dragging tasks onto the map).
If somebody could please further clarify how to handle this, I would greatly appreciate it. It should be noted I also tried having the Address class extend the Pushpin class, without success. I didn't think this was necessary, however, because the WPF samples were simple POCO's.
Consider a simple class like the following:
public
class
Address
{
public
Location Location {
get
;
set
; }
public
string
Address {
get
;
set
; }
public
string
City {
get
;
set
; }
public
string
State {
get
;
set
; }
public
string
Zip {
get
;
set
; }
}
I'd like to be able to add a pin to the map for each Address. My intent is to eventually provide hover functionality so that a popup displays information over the pin when the mouse hovers over it, but I haven't gotten the pins to display. In the view model, I have a property of type ObservableCollection<Address>. I then bind to the address collection in the XAML with the following:
<
telerik:InformationLayer
ItemsSource
=
"{Binding AddressPins}"
/>
I understand I will have to create an item template in order to achieve the hover affect I'm looking for, but it is my understanding the above code should render pins for each location specified by an Address object. The following is an ICommand that handles the DragDropManager's OnDropInfo event (I'm dragging tasks onto the map).
if
(e.Options.Status == DragStatus.DropComplete)
{
RadMap map = (RadMap)e.Options.Destination;
Location dropCursorLocation = Location.GetCoordinates(map, e.Options.RelativeDragPoint);
Entity.Task task = (Entity.Task)e.Options.Payload;
Address pin =
new
Address
{
Address = task.Address,
City = task.City,
Location = dropCursorLocation,
State = task.State
Zip = task.Zip
};
System.Diagnostics.Debug.WriteLine(
"Dropped at Latitude: {0} - Longitude: {1}"
, dropCursorLocation.Latitude, dropCursorLocation.Longitude);
// Add pin to the map
this
.AddressPins.Add(pin);
e.Handled =
true
;
}
If somebody could please further clarify how to handle this, I would greatly appreciate it. It should be noted I also tried having the Address class extend the Pushpin class, without success. I didn't think this was necessary, however, because the WPF samples were simple POCO's.