Removed LocationPath property from MapItem and PushPin.

This commit is contained in:
ClemensF 2012-12-06 23:28:12 +01:00
parent b0ecd850a2
commit d0d949c9be
17 changed files with 88 additions and 133 deletions

View file

@ -37,7 +37,7 @@
</Setter>
</Style>
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
<Setter Property="LocationPath" Value="Location"/>
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Template">
@ -83,12 +83,12 @@
</Setter>
</Style>
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
<Setter Property="LocationPath" Value="Location"/>
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ControlTemplate TargetType="map:MapItem">
<map:Pushpin Content="{Binding Name}"/>
</ControlTemplate>
</Setter.Value>

View file

@ -0,0 +1,36 @@
using MapControl;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace StoreApplication
{
public class BindingHelper
{
public static readonly DependencyProperty LocationPathProperty = DependencyProperty.RegisterAttached(
"LocationPath", typeof(string), typeof(BindingHelper),
new PropertyMetadata(null, LocationPathPropertyChanged));
public static string GetLocationPath(DependencyObject obj)
{
return (string)obj.GetValue(LocationPathProperty);
}
public static void SetLocationPath(DependencyObject obj, string value)
{
obj.SetValue(LocationPathProperty, value);
}
private static void LocationPathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var propertyPath = e.NewValue as string;
if (propertyPath != null)
{
BindingOperations.SetBinding(
obj,
MapPanel.LocationProperty,
new Binding { Path = new PropertyPath(propertyPath) });
}
}
}
}

View file

@ -35,7 +35,7 @@
</Setter>
</Style>
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
<Setter Property="LocationPath" Value="Location"/>
<Setter Property="local:BindingHelper.LocationPath" Value="Location"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Foreground" Value="Black"/>
@ -82,13 +82,13 @@
</Setter>
</Style>
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
<Setter Property="LocationPath" Value="Location"/>
<Setter Property="local:BindingHelper.LocationPath" Value="Location"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ControlTemplate TargetType="map:MapItem">
<map:Pushpin Content="{Binding Name}"/>
</ControlTemplate>
</Setter.Value>
@ -122,7 +122,8 @@
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}"
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
<!--<map:Pushpin map:MapPanel.Location="53.5,8.2" Background="Yellow" Foreground="Blue" Content="N 53° 30' E 8° 12'"/>-->
<!-- No TypeConverter (yet?) for string to Location
<map:Pushpin map:MapPanel.Location="53.5,8.2" Background="Yellow" Foreground="Blue" Content="N 53° 30' E 8° 12'"/>-->
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="4" FontSize="10"
Text="{Binding TileLayer.Description, ElementName=map}"/>

View file

@ -103,6 +103,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="BindingHelper.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>

View file

@ -127,7 +127,7 @@
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ControlTemplate TargetType="map:MapItem">
<map:Pushpin Content="{Binding Name}"/>
</ControlTemplate>
</Setter.Value>