Мне нужна помощь, как сделать привязку к ZoomLevel Property и Center Property?Я смог сделать привязку для PushPins, но ZoomLevel и Center я не знаю, как связывать Спасибо!
<UserControl x:Class="AppGST.BingMaps"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AppGST"
xmlns:map="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
mc:Ignorable="d"
d:DesignHeight="628" d:DesignWidth="800">
<UserControl.Resources>
<DataTemplate x:Key="MapTemplate">
<map:Pushpin map:MapLayer.Position="{Binding Location}"/>
</DataTemplate>
</UserControl.Resources>
<Grid>
<map:Map Height="628"
CredentialsProvider="{StaticResource Key}"
ZoomLevel="2"
Mode="Road"
Name="WorldMap">
<map:MapItemsControl ItemsSource="{Binding PinsLocations}" ItemTemplate="{StaticResource MapTemplate}"/>
</map:Map>
</Grid>
Класс ViewModel
public class BingMapsViewModel : ObserverableObject, IPageViewModel
{
private ObservableCollection<MapModel> _pinsLocations;
public ObservableCollection<MapModel> PinsLocations
{
get { return _pinsLocations; }
set
{
_pinsLocations= value;
OnPropertyChanged();
}
}
public BingMapsViewModel()
{
GSTService.GetRecentLocationDataForGST((o, ea) =>
{
GSTLocations = new ObservableCollection<MapModel>(ea.Locations);
});
}
}
public class GSTService
{
public static void GetRecentLocationDataForGST(EventHandler<GSTLocationsEventArgs> callback)
{
List<MapModel> data = new List<MapModel>();
data.Add(new MapModel { Location = new Location(32.021944, 34.757732), ZoomLevel = 18 });
data.Add(new MapModel { Location = new Location(43.273558, 76.914842), ZoomLevel = 18 });
data.Add(new MapModel { Location = new Location(55.753215, 37.622504), ZoomLevel = 18 });
callback(null, new GSTLocationsEventArgs(data));
}
}
public class GSTLocationsEventArgs: EventArgs
{
public List<MapModel> Locations { get; set; }
public GSTLocationsEventArgs(List<MapModel>locations)
{
Locations = locations;
}
}
Открытый класс модели MapModel: ObserverableObject {private Location _location;private double_zoomLevel;
public double ZoomLevel { get; set; }
public Location Location { get; set; }
}