我使用 MVVM 模式在 WPF 中创建了一个应用程序。
该应用程序在 Visual Studio 调试器中运行良好,但是当我从 debug/release 文件夹运行 exe 时,它变得非常慢。
这是我的RelayCommand课:
public class RelayCommand : ICommand
{
private readonly Action<object> execute;
private readonly Predicate<object> canExecute;
public RelayCommand(Action<object> execute) : this(execute, DefaultCanExecute)
{
}
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
this.execute = execute;
this.canExecute = canExecute;
}
public event EventHandler CanExecuteChanged
{
add
{
CommandManager.RequerySuggested += value;
}
remove
{
CommandManager.RequerySuggested -= value;
}
}
[DebuggerStepThrough]
public bool CanExecute(object parameter)
{
bool res = false;
if …Run Code Online (Sandbox Code Playgroud) 我想获得一些选定的行项目并尝试操纵它们.目前SelectedItem一次只给我一行.而且SelectedItems不是依赖属性.我通过创建自己的依赖属性来获取所选项目,从而找到了解决方案.除此之外有什么选择吗?