[英]Add button on map when pin/marker is clicked (xamarin forms)
單擊圖釘后,我需要在地圖上添加一個按鈕。 我將xamarin表單和googlemaps用於iOS和Android。
這是我的XAML:
<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ContentView Content="{Binding Map}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" AbsoluteLayout.LayoutBounds = "1, 1, 1, 1" AbsoluteLayout.LayoutFlags = "All"/>
<Button BackgroundColor="White" IsVisible="{Binding IsPinVisible}" Text="{Binding NewAddress}" TextColor="Blue" AbsoluteLayout.LayoutBounds = "1, 0, 1, 0.15" AbsoluteLayout.LayoutFlags = "All"/>
</AbsoluteLayout>
我的ViewModel帶有布爾值和字符串:
private bool _isPinVisible;
public bool IsPinVisible
{
get
{
return _isPinVisible;
}
set
{
_isPinVisible = value;
RaisePropertyChanged(nameof(IsPinVisible));
}
}
private string _newaddress;
public string NewAddress
{
get
{
return _newaddress;
}
set
{
_newaddress = value;
RaisePropertyChanged(nameof(NewAddress));
}
}
我有Map.PinClicked事件的Viewmodel:
Map.PinClicked += (sender, args) =>
{
IsPinVisible = true;
_newaddress = Address;
};
一旦我點擊現在的圖釘,就會顯示一個白色的空白區域,但是沒有文本。 當我更新LiveXaml更改文本顏色時,將顯示文本。
我不得不使用NewAddress
Map.PinClicked += (sender, args) =>
{
IsPinVisible = true;
NewAddress = Address;
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.