XAML-Map-Control/MapControl/MapItem.cs

50 lines
1.5 KiB
C#
Raw Normal View History

// 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)
#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;
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>
public partial class MapItem : ListBoxItem
2012-04-25 22:02:53 +02:00
{
public static readonly DependencyProperty LocationPathProperty = DependencyProperty.Register(
"LocationPath", typeof(string), typeof(MapItem), new PropertyMetadata(null, LocationPathPropertyChanged));
/// <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
{
get { return (string)GetValue(LocationPathProperty); }
set { SetValue(LocationPathProperty, value); }
2012-04-25 22:02:53 +02:00
}
private static void LocationPathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
2012-04-25 22:02:53 +02:00
{
string path = e.NewValue as string;
2012-04-25 22:02:53 +02:00
if (!string.IsNullOrWhiteSpace(path))
2012-04-25 22:02:53 +02:00
{
var binding = new Binding
{
Path = new PropertyPath(path)
};
2012-04-25 22:02:53 +02:00
BindingOperations.SetBinding(obj, MapPanel.LocationProperty, binding);
2012-04-25 22:02:53 +02:00
}
}
}
}