命令绑定在弹出窗口中不起作用

时间:2018-09-25 09:41:20

标签: wpf xaml

我正在使用命令绑定,该命令绑定在其他相似的窗口中也可以,但没有一个。我检查了 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);
}

1 个答案:

答案 0 :(得分:0)

尝试在打开弹出窗口时初始化命令:

7.3