相关文章推荐
坚强的木耳  ·  金陵- 教育百科| 教育雲線上字典·  9 月前    · 
喝醉的便当  ·  战火熔炉剧情介绍(1-13全集)大结局_电视 ...·  10 月前    · 
踢足球的草稿本  ·  快速缓解酒精过敏不妨试试这些方法_手机新浪网·  10 月前    · 
被表白的日记本  ·  HR 的工作是什麼?人資必備8 ...·  11 月前    · 
冷静的签字笔  ·  令人驚豔的細心設定:盤點《無法成為野獸的我們 ...·  11 月前    · 
小百科  ›  C# WPF CheckBox命令未绑定开发者社区
wpf object
聪明的绿茶
2 年前
首页
学习
活动
专区
工具
TVP
返回腾讯云官网
提问
问 C# WPF CheckBox命令未绑定
Stack Overflow用户
提问于 2022-04-29 02:29:22
EN

查看:

 <DataGridTemplateColumn.Header>
     <CheckBox x:Name="chk_Top" HorizontalAlignment="Center" HorizontalContentAlignment="Center"
         Command="{Binding Chk_GridTop}"/>
 </DataGridTemplateColumn.Header>

视图模型:

public partial class ViewModel_AC: INotifyPropertyChanged
    ICommand _chkGridTop;
    public ICommand Chk_GridTop
        get { return _chkGridTop ?? (_chkGridTop = new DelegateCommand(_chk_GridTop)); }
    public void _chk_GridTop(object check)
     //Empty
}

DelegateCommand

public class DelegateCommand : ICommand
    readonly Action<object> _execute;
    readonly Predicate<object> _canExecute;
    public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
        if (execute == null)
            throw new NullReferenceException("execute can no null");
        _execute = execute;
        _canExecute = canExecute;
    public DelegateCommand(Action<object> execute) : this(execute, null)
    public event EventHandler CanExecuteChanged
        add { CommandManager.RequerySuggested += value; }
        remove { CommandManager.RequerySuggested -= value; }
    public bool CanExecute(object parameter)
        return _canExecute == null ? true : _canExecute(parameter);
    public void Execute(object parameter)
 
推荐文章
坚强的木耳  ·  金陵- 教育百科| 教育雲線上字典
9 月前
喝醉的便当  ·  战火熔炉剧情介绍(1-13全集)大结局_电视剧_电视猫
10 月前
踢足球的草稿本  ·  快速缓解酒精过敏不妨试试这些方法_手机新浪网
10 月前
被表白的日记本  ·  HR 的工作是什麼?人資必備8 大職能與系統應用- 資通電腦
11 月前
冷静的签字笔  ·  令人驚豔的細心設定:盤點《無法成為野獸的我們》中的啤酒與酒杯 ...
11 月前
Link管理   ·   Sov5搜索   ·   小百科
小百科 - 百科知识指南