MessageBox弹出ComboBox下拉列表,遮蔽MessageBox中的内容 [英] MessageBox pops up behind ComboBox drop down list, obscuring content in MessageBox

查看:617
本文介绍了MessageBox弹出ComboBox下拉列表,遮蔽MessageBox中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在进行的项目中,我有一个ComboBox,其日期根据应用程序中其他地方的某些其他标准计算人的年龄。

In a project I am working on, I have a ComboBox with dates that calculates the persons age depending on certain other criteria elsewhere in the application.

如果用户选择日期,我们会向用户弹出一个通知,告知我们由于此原因而更改了表单上的一些内容。

If the user selects a date, we pop up a notification to the user that we changed a few things on the form due to this.

如图所示,组合框的项目在弹出时仍然停留在消息框的顶部。用户仍然可以单击确定,并可以移动框,但这是一种奇怪的方式向用户显示信息。

As you can see in the picture, the combobox's items end up still staying on top of the messagebox when it pops up. The user can still click OK, and can move the box, but this is an odd way to present information to the user.

是否有一种方法来弹出消息或者在消息框出现之前隐藏列表?我试图设置IsDropDownOpen,但这不工作。

Is there a way to pop up the message box above this list, or hide the list before the messagebox comes up? I tried setting IsDropDownOpen, but that doesn't work.

更新:MessageBox.Show事件发生在选择更改,这就是为什么我认为它还没有关闭下拉。

Update: The MessageBox.Show event happens in the selection changed, which is why I figured it hadn't closed the drop down yet. How could one get around this though?

更新2 :代码我目前是这样的。 ComboBox使用LostFocus事件(处理打字和/或选择)来调用CheckDOB方法。 CheckDOB是我在那里显示MessageBox

Update 2: Code I currently have goes like this. ComboBox uses a 'LostFocus' event (to handle typing and/or selecting) to call a CheckDOB method. CheckDOB is where I then show the MessageBox

推荐答案

我不能重现你的问题,但我相信使用Dispatcher可以帮助。

Well I can't reprodouce your issue, but I believe that using the Dispatcher can help.

请尝试以下操作:

VB.NET b
$ b

VB.NET

  Private Sub ComboBox_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs)
        'Do what you need..
        Me.Dispatcher.BeginInvoke(Sub()
                                      MessageBox.Show("Message", "Caption", MessageBoxButton.OK, MessageBoxImage.Information)
                                  End Sub)
    End Sub

C#

private void ComboBox_SelectionChanged(System.Object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
    //Do what you need..
     Dispatcher.BeginInvoke(new ThreadStart(() =>
     {

         MessageBox.Show("Message", "Caption", MessageBoxButton.OK, MessageBoxImage.Information); 

      }));
}

这篇关于MessageBox弹出ComboBox下拉列表,遮蔽MessageBox中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆