2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2012-05-04 12:52:20 +02:00
|
|
|
|
// Copyright © 2012 Clemens Fischer
|
|
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
#if WINRT
|
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
|
#else
|
2012-04-25 22:02:53 +02:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
#endif
|
2012-04-25 22:02:53 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2012-05-04 12:52:20 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Container class for an item in a MapItemsControl.
|
|
|
|
|
|
/// </summary>
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public partial class MapItem : ListBoxItem
|
2012-04-25 22:02:53 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public static readonly DependencyProperty LocationPathProperty = DependencyProperty.Register(
|
|
|
|
|
|
"LocationPath", typeof(string), typeof(MapItem), new PropertyMetadata(null, LocationPathPropertyChanged));
|
2012-08-22 20:21:31 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the property path that is used to bind the MapPanel.Location attached property.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string LocationPath
|
2012-04-25 22:02:53 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
get { return (string)GetValue(LocationPathProperty); }
|
|
|
|
|
|
set { SetValue(LocationPathProperty, value); }
|
2012-04-25 22:02:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
private static void LocationPathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
2012-04-25 22:02:53 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
string path = e.NewValue as string;
|
2012-04-25 22:02:53 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(path))
|
2012-04-25 22:02:53 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
var binding = new Binding
|
|
|
|
|
|
{
|
|
|
|
|
|
Path = new PropertyPath(path)
|
|
|
|
|
|
};
|
2012-04-25 22:02:53 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
BindingOperations.SetBinding(obj, MapPanel.LocationProperty, binding);
|
2012-04-25 22:02:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|