Hello Stackoverflow community! I've started recently building a flight dashboard, including Bing Maps WPF Control in MVVM patters (at least as much, as possible) for Windows PC devices.
After seeking the web for a while I was able to deliver CredentialsProvider based on the key in app.config and moved to implement automatic centering of the Bing's control map based on the current device's position.
The XAML:
<m:Map ZoomLevel="16" Mode="Aerial" CredentialsProvider="{Binding BingMapsCredentials}" Grid.Row="1" Grid.ColumnSpan="2" Center="{Binding DevPosition}"/>
The ViewModel:
private readonly CredentialsProvider bingMapsCredentials = new ApplicationIdCredentialsProvider(ConfigurationSettings.AppSettings.Get("BingMapsKey"));
private readonly double nDefaultLatitude = double.Parse(ConfigurationSettings.AppSettings.Get("DefaultLongitude"), System.Globalization.CultureInfo.InvariantCulture);
private readonly double nDefaultLongitude = double.Parse(ConfigurationSettings.AppSettings.Get("DefaultLatitude"), System.Globalization.CultureInfo.InvariantCulture);
private GeoCoordinate nDevicePosition;
public CredentialsProvider BingMapsCredentials
{
get { return bingMapsCredentials; }
}
public Location DevPosition
{
get { return new Location(nDeviceLat, nDeviceLon); }
}
public double nDeviceLon
{
get
{
if (nDevicePosition.IsUnknown)
return nDefaultLongitude;
else
return nDevicePosition.Longitude; }
set { nDevicePosition.Longitude = value; }
}
public double nDeviceLat
{
get
{
if (nDevicePosition.IsUnknown)
return nDefaultLatitude;
else
return nDevicePosition.Latitude;
}
set { nDevicePosition.Latitude = value; }
}
While binding the CredentialsProvider works fine, setting the Center location does not at all. The map is displayed correctly but somewhere in the middle of nowhere. The debugger shows that there is no call on the Get property on location. There are also no WPF warning/error traces in the Output Window.
Am I missing something here?
Any help is appreciated.
P.
VMimplementsINotfiyPropertyChanged? - XAMlMAX