c# - 如果我单击它上面的按钮,WPF 子窗口将关闭

标签 c# wpf

if (VendorSettingWondow == null)
{
    VendorSettingWondow = new VendorSettingWindow();
    VendorSettingWondow.Top = this.Top;
    VendorSettingWondow.Left = this.Left + this.Width/2;
    //VendorSettingWondow.Visibility = Visibility.Visible;
    VendorSettingWondow.injdf.Text = filename; // setting file name
    VendorSettingWondow.inJDFVendorInfo.ItemsSource = inJDFVendors;
   // VendorSettingWondow.inJDFVendorInfo.ItemsSource = vendorList.Vendors;
    VendorSettingWondow.DBVendorList.ItemsSource = DBvendorList.Vendors;
    VendorSettingWondow.ShowDialog();
}

如果在主窗口中满足某些条件,我将创建一个子窗口,如上所示。我的子窗口中有两个按钮。当我单击按钮时,子窗口正在关闭。我正在使用 ShowDialog() 因为我想在创建子窗口时控制从主窗口转移到子窗口

最佳答案

检查按钮的 IsCancel 属性。如果它设置为 true,请将其设置为 false 以防止按钮关闭对话框。

关于c# - 如果我单击它上面的按钮,WPF 子窗口将关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40077107/

相关文章:

c# - 防止 ASP.Net 项目将 {assembly}.dll.config 复制到 bin 文件夹

C# Process.Start "chrome.exe"/声明高度

wpf - 如何将 Themes/Generic.xaml 连接到 window1.xaml?

c# - 使用外部辅助类

c# - 如何将控件的属性值传递给 WPF 中同一控件的 "CommandParameter"属性

c# - 寻找一个项目的想法

c# - FluentValidation:在子集合规则中使用父属性值

c# - "For money, always decimal"?

c# - 如何在 C# 中捕获删除按键?

c# - 如何释放 MediaElement 使用的内存