C#/WPF

[WPF]Command

딸기우유중독 2022. 12. 14. 10:34

ViewModel에 정의 되어있는 Command 호출방법.

 

정의 되어있는 Command

        private DelegateCommand<string> copySelectedDeviceCommand;
        public DelegateCommand<string> CopySelectedDeviceCommand =>
            copySelectedDeviceCommand ?? (copySelectedDeviceCommand = new DelegateCommand<string>(ExecuteCopySelectedDeviceCommand));

        void ExecuteCopySelectedDeviceCommand(string parameter)
        {
            Clipboard.SetText(SelectedDeviceName);
        }

 

호출

CopySelectedDeviceCommand.Execute(null);

Type에 맞는 제네릭 파라미터로 전달. Ex) string, object, etc.

728x90