如果单击上面的按钮,WPF子窗口将关闭

时间:2016-10-17 00:51:07

标签: 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(),因为我想控制在创建子窗口时从主窗口转移到子窗口

1 个答案:

答案 0 :(得分:3)

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