C#/WPF

[WPF] CommandParameter 로 자신 값 보내기 (self Binding)

kjun.kr 2022. 4. 22. 08:16
728x90
728x170

xaml

      <CheckBox
      Command="{Binding SelfTestCommand}"
      CommandParameter="{Binding RelativeSource={RelativeSource self}, Path=IsChecked}"/>

cs

        private DelegateCommand<bool?> selfTestCommand;

        /// <summary>
        /// SelfTest Command
        /// </summary>
        public ICommand SelfTestCommand
        {
            get
            {
                if (this.selfTestCommand== null)
                {
                    this.selfTestCommand= new DelegateCommand<bool?>((param) => OnSelfTestCommand(param));
                }

                return this.selfTestCommand;
            }
        }

        private void OnFalseCallCommand(bool? isChecked)
        {
        }

 

728x90
그리드형