Topic: TextBox and Popup

Prompt about Popup.
I should open a pop-up window when the user pushes on TextBox and not to hide Popup while the text box has focus.

<TextBox x:Name = "textBox" GotFocus = "textBox_GotFocus"/>
<Button Content = "Button" Click = "Button_Click"/>
<Popup x:Name = "popup" Width = "100" Height = "100" PlacementTarget = "{Binding ElementName=textBox}" Placement = "Bottom"
StaysOpen = "{Binding ElementName=text, Path=IsKeyboardFocused}">
<Grid Background = "Blue">
private void Button_Click (object sender, RoutedEventArgs e)
popup. IsOpen = false;
private void textBox_GotFocus (object sender, RoutedEventArgs e)
popup. IsOpen = true;

I found property StaysOpen = "{Binding ElementName =, Path=IsKeyboardFocused}". But at application of it Popup ceases to disappear, when I push outside of Popup. It is necessary to close Popup forcedly for each component on the form, for example at button click. Besides, I do not understand how to close Popup, if to open Window in a conversational mode (ShowDialog) when the user clicks outside of Window.
In other situations, it is not required the forced closing Popup, it is enough to specify StaysOpen = "false".
Help to make correctly Popup for TextBox.


Re: TextBox and Popup

Iconfig wrote:

not to hide Popup while the text box has focus.

can so?

IsOpen = "{Binding ElementName =, Path=IsKeyboardFocused}"

: for XAML-code design use a tag xml, instead of C#


Re: TextBox and Popup

There is such problem.
TextBox it is made MouseCapture outside of Popup windows because of what capture popup windows of a mouse is cancelled and it is not recovered. Thus, if there will be all happens inside Popup (TextBox is inside Popup windows) capture by mouse Popup of a window will be recovered, after capture TextBox.
I solved it simply, opened Popup a window atop Textbox', in Popup there was TextBox, appear, that it anywhere and did not disappear smile but it is other text boxing with search \filtration or everything.


Re: TextBox and Popup

Shocker. Pro;
IsOpen = "{Binding ElementName=textBox,Path=IsKeyboardFocused, Mode=OneWay}". Does not help, it is not closed Popup.


Re: TextBox and Popup

Roman Mejtes;
Thanks for the help!