我需要添加一个按钮在地图上,当我点击了引脚。我在ios和android上使用xamarin表单和googlemaps。
这是我的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>
带bool和string的我的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));
}
}
我的viewmodel中有map.pinclicked事件:
Map.PinClicked += (sender, args) =>
{
IsPinVisible = true;
_newaddress = Address;
};
从现在起,当我单击pin时,会出现一个白色空白区域,但没有文本。当我更新livexaml以更改文本显示的文本颜色时。