독개

[Avalonia] Execute , CanExecute

by #독개#

결과물 이미지

 

axaml


<TextBox Watermark="프로세스명 입력" Text="{Binding ProcessName}"> </TextBox>
<TextBox Watermark="Class명 입력" Text="{Binding ClassName}"> </TextBox>
<Button Content="스크린샷 찍기" Command="{Binding Capture}"></Button>

ViewModel

 
private string _ProcessName;
public string ProcessName { get => _ProcessName; set { this.RaiseAndSetIfChanged(ref _ProcessName, value); } }

private string _ClassName;
public string ClassName { get => _ClassName; set { this.RaiseAndSetIfChanged(ref _ClassName, value); } }

public void Capture()
{
	//캡쳐버튼 눌렀을때 Execute
}


 [DependsOn(nameof(ProcessName)),DependsOn(nameof(ClassName))] //Depends On 걸어줘야 트리거연결
    public bool CanCapture(object obj)
    {
        if (!string.IsNullOrEmpty(ProcessName) || !string.IsNullOrEmpty(ClassName))
            return true;
        return false;
    }

 

블로그의 정보

독한 개발자

#독개#

활동하기