簡體   English   中英

在WPF中,如何將參數傳遞給ICommand.CanExecute()

[英]In WPF, how to pass a parameter to ICommand.CanExecute()

public bool SelectAll
    {
        get { return this.Get<bool>("SelectAll"); }
        set 
        {
            this.Set<bool>("SelectAll", value);
            if (this.SelectAllCommand.CanExecute(null))
                this.SelectAllCommand.Execute(value);
        }
    }

作為我的代碼,我想要一個復選框-選擇所有功能。 當我手動單擊“全選”時,我想執行SelectAllCommand,但是如果自動選中了該復選框,則CanExecute應該向我返回false。

我沒有如何將參數傳遞給CanExecute ...我該怎么做...?

提前致謝

好吧,在您的代碼中,您當前正在傳遞一個參數,該參數恰好為空。 所以你不是更准確地想做

if (this.SelectAllCommand.CanExecute(value))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM