在用户控件网格(Grid1)中,我有一个文本框、两个按钮(搜索和保存按钮)和两个弹出窗口(Popup1 和 Popup2)。在 Popup2 里面有一个文本框和一个按钮(搜索)。当用户在 Grid1 外部单击时,我想隐藏弹出窗口(1 和 2)。现在我可以隐藏弹出窗口,但无法单击 Popup2 中的按钮。一旦我单击 Popup2 内的 SearchButton,它就会隐藏弹出窗口。
我已将两个 Popups 的 StaysOpen 属性设置为 bool 属性,如下所示:StaysOpen="{Binding PopupStaysOpen}"
谢谢。-梅农
private void Grid1_LostFocus(object sender, RoutedEventArgs e)
{
(this.DataContext as ViewModel).PopupStaysOpen = false;
}