简体   繁体   English

单击messagebox.show()隐藏showdialog()窗口

[英]clicking messagebox.show() hides showdialog() window

I have following code in WPF: 我在WPF中有以下代码:

 private void BtnTicketPrice_Click(object sender, RoutedEventArgs e)
    {
        TicketPrice TP = new TicketPrice();
        TP.ShowDialog();
    }

in New Window form i have following code: 在新窗口形式下,我有以下代码:

private void BtnSave_Click(object sender, RoutedEventArgs e)

        {
                MessageBox.Show("sometext");
        }

on clicking messagebox button the form ( TicketPrice ) also is closing; 在单击消息框按钮时,表单( TicketPrice )也将关闭; how to show messagebox without closing the form? 如何显示消息框而不关闭表单?

If i'd change TP.ShowDialog(); 如果我要更改TP.ShowDialog(); to TP.Show(); TP.Show(); , it works correctly. ,它可以正常工作。 I have this problem only with this TP.ShowDialog(); 我只有这个TP.ShowDialog()有这个问题。

xaml of button 按钮的xaml

    <Button x:Name="BtnSave" HorizontalAlignment="Left" Margin="619,362,0,0" VerticalAlignment="Top" Width="165" Height="66" IsCancel="True" TabIndex="4" Click="BtnSave_Click"> 
<StackPanel Orientation="Horizontal"> 
<TextBlock Text="save " HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="SemiBold" /> 
<Image Source="pack://siteoforigin:,,,/Resources/Save.png" Height="50" Width="59" /> 
</StackPanel> 
</Button>

You're seeing the IsCancel property on the Button working as advertised. 您会看到Button上的IsCancel属性按宣传的方式工作。 Don't set it to true and clicking the button won't automatically close the dialog. 不要将其设置为true并且单击按钮不会自动关闭对话框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM