2 回答
TA贡献1824条经验 获得超5个赞
你不能这样做IsVisible="{Binding !isConnecting}",这是行不通的。
您可以制作 InvertBoolConverter,或者更简单的选项是使用触发器。这是一个示例:
<Label Text="PlaceholderText" TextDecorations="Underline" TextColor="White" Margin="0,5,0,0" HorizontalTextAlignment="Center"
IsVisible="{Binding isConnecting}">
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding isConnecting}" Value="True">
<Setter Property="IsVisible" Value="False" />
</DataTrigger>
<DataTrigger TargetType="Label" Binding="{Binding isConnecting}" Value="False">
<Setter Property="IsVisible" Value="True" />
</DataTrigger>
</Label.Triggers>
</Label>
TA贡献1859条经验 获得超6个赞
您可以改进您的代码ViewModel
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private bool isconnecting ;
public bool isConnecting
{
get
{
return isconnecting;
}
set
{
if (isconnecting != value)
{
isconnecting = value;
NotifyPropertyChanged();
}
}
}
- 2 回答
- 0 关注
- 90 浏览
添加回答
举报