我正在使用命令绑定,该命令绑定在其他相似的窗口中也可以,但没有一个。我检查了 DataContext 并发现它是正确的。实际上,事件EventHandler CanExecuteChanged
从未受到攻击。
对于XAML,将Codebehind设置为 DataContext
XAML
<Button CommandParameter="Flow" Content="Test"
Command="{Binding SetAutoYAxisCommand, Mode=OneWay}" />
隐藏代码
public RelayCommand ExportHistoricalCommand { get; set; }
public RelayCommand1 SetAutoYAxisCommand { get; set; }
public TransientPipeDialog(TransientPipeModel transientPipeModel)
{
InitializeComponent();
this.ParentModel = transientPipeModel;
this.TransientPipeModel = transientPipeModel.DeepCopy();
ExportHistoricalCommand = new RelayCommand(ExportHistoricalData);
SetAutoYAxisCommand = new RelayCommand1(SetAutoYAxis, o => true);
}
答案 0 :(得分:0)
尝试在打开弹出窗口时初始化命令:
7.3