我有一个带有按钮选择/取消的mapControl和两个用于查看坐标的TextBlock。点击选择按钮后,正在计算地址是从获取坐标(LatitudeMap和LongitudeMap)。
private async void SelectCoordinate_Tapped(object sender, TappedRoutedEventArgs e)
{
LatitudeText = LatitudeMap;
LongitudeText = LongitudeMap;
MapLocationFinderResult result = await reverseGeocode(sender, e);
if (result.Status == MapLocationFinderStatus.Success)
{
AddressText = result.Locations[0].Address.Town + "," + result.Locations[0].Address.Street + "," + result.Locations[0].Address.StreetNumber;
}
MapVisibility = false;
}
LatitudeMap和LongitudeMap在点击地图后得到:
private void AddMapIcon_Tapped(MapControl sender, MapInputEventArgs args)
{
MapIcon icon;
icon = new MapIcon();
if (icon != null)
{
MapWithPin.MapElements.Clear();
}
var tappedGeoPosition = args.Location.Position;
Geopoint Point = new Geopoint(new BasicGeoposition() { Latitude = tappedGeoPosition.Latitude, Longitude = tappedGeoPosition.Longitude });
icon = new MapIcon { Location = Point, NormalizedAnchorPoint = new Point(0.5, 1.0), ZIndex = 0 };
MapWithPin.MapElements.Add(icon);
MapWithPin.Center = Point;
LatitudeMap = Convert.ToString(tappedGeoPosition.Latitude);
LongitudeMap = Convert.ToString(tappedGeoPosition.Longitude);
Select.IsEnabled = true;
}
问题是在LontitudeTextBlock中没有看到LontitudeText。
答案 0 :(得分:0)
我认为问题是LongitudeTexttProperty
依赖项属性名称中的拼写错误。它应该是LongitudeTextProperty
。
答案 1 :(得分:0)
public string LatitudeText
{
get { return (string)GetValue(LatitudeTextProperty); }
set { SetValue(LatitudeTextProperty, value); }
}
public static readonly DependencyProperty LatitudeTextProperty =
DependencyProperty.Register(nameof(LatitudeText), typeof(string), typeof(AddLocationControl), new PropertyMetadata(null, (d, e) => {}));
public string LongitudeText
{
get { return (string)GetValue(LongitudeTextProperty); }
set { SetValue(LongitudeTextProperty, value); }
}
public static readonly DependencyProperty LongitudeTextProperty =
DependencyProperty.Register(nameof(LongitudeText), typeof(string), typeof(AddLocationControl), new PropertyMetadata(null, (d, e) => {}));
正确的财产。