isEditorVisible
财产。
我已成功地将条目IsVisible参数绑定到
您正在使用
Editor
Entry
. 另外,你正在绑定
Command
命令
在你的
ViewModel
ChangeBoolValue
. 您没有使用
Behavior<T>
<Editor x:Name="TextEntry" Grid.Row="1" VerticalOptions="FillAndExpand" IsVisible="{Binding SwitchVisible, Mode=TwoWay}"/>
所以你想要达到的是
编辑
IsVisibleProperty将根据
SwitchIsVisible
属性,你绑定到哪一个,对吗?
我将在ViewModel中执行类似的操作,而不是实际实现:
public event PropertyChangedEventHandler PropertyChanged;
public ICommand ChangeBoolValue { protected set; get; }
public ICommand Debug { protected set; get; }
private bool _switchVisible;
public bool SwitchVisible
{
get => _switchVisible;
set
{
if(_switchVisible == value) return;
_switchVisible = value;
OnPropertyChanged("SwitchVisible");
}
}
public HandleEditor()
{
ChangeBoolValue = new Command(() =>
{
SwitchVisible = !SwitchVisible;
});
}
protected virtual void OnPropertyChanged(string propertyName)
{
System.Diagnostics.Debug.WriteLine("Debug: OnPropertyChanged has been fired " + propertyName + " : " + isEditorVisible);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public void Pin_Clicked(CustomPin pin)
{
SwitchVisible = true;
}