by Anonymous » 17 Aug 2025, 01:24
Aus irgendeinem Grund, obwohl ich zuerst commandParameter eingestellte, wird CaneExecute mit null .
-matters ding. Alle außer dem .NET7.0 eins.
Code: Select all
WinExe
net461;net481;net6.0-windows;net7.0-windows
enable
enable
preview
true
mainwindow.xaml
mainwindow.xaml.cs
Code: Select all
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
namespace CommandParameterBug;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
public class ViewModel
{
public ICommand Cmd { get; }
public ViewModel()
{
Cmd = new TestCommand();
}
}
public class TestCommand : ICommand
{
public event EventHandler? CanExecuteChanged;
public bool CanExecute(object? parameter)
{
Debug.WriteLine($"CanExecute: {parameter}");
return parameter != null;
}
public void Execute(object? parameter)
{
}
}
Aus irgendeinem Grund, obwohl ich zuerst commandParameter eingestellte, wird CaneExecute mit null .[code]CommandParameter[/code] -matters ding. Alle außer dem .NET7.0 eins.[code]
WinExe
net461;net481;net6.0-windows;net7.0-windows
enable
enable
preview
true
[/code]
[b] mainwindow.xaml[/b]
[code]
[/code]
[b] mainwindow.xaml.cs[/b]
[code]using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
namespace CommandParameterBug;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
public class ViewModel
{
public ICommand Cmd { get; }
public ViewModel()
{
Cmd = new TestCommand();
}
}
public class TestCommand : ICommand
{
public event EventHandler? CanExecuteChanged;
public bool CanExecute(object? parameter)
{
Debug.WriteLine($"CanExecute: {parameter}");
return parameter != null;
}
public void Execute(object? parameter)
{
}
}
[/code]