我想要一个按钮来更改标签的可见性,一旦我单击它。
xaml视图:
<local:ButtonRenderer Text="Connect" BackgroundColor="#6DCFF6" TextColor="White" Command="{Binding viewTemperature}" CornerRadius="10" WidthRequest="200" IsVisible="{Binding !isConnecting}"/>
<Label Text="PlaceholderText" TextDecorations="Underline" TextColor="White" Margin="0,5,0,0" HorizontalTextAlignment="Center" IsVisible="{Binding !isConnecting}"/>
视图模型
viewTemperature = new Command(async () =>
{
isConnecting = true;
await _navigation.PushModalAsync(new TemperaturePage());
}) ;
public bool isConnecting
{
get
{
return _isConnecting;
}
set
{
_isConnecting = value;
PropertyChanged?.Invoke(this, new
PropertyChangedEventArgs(_isConnecting.ToString()));
}
}
我已经在代码中放置了断点,并且 isConnected 在我的视图模型中被更改为 true。但是,我的标签的可见性没有改变。我怀疑这PropertyChanged不应该改变布尔值?
沧海一幻觉
BIG阳
相关分类