My popup has button in it (just to test). When I move the mouse over the Panel inside the WindowsFormsHost, I show the popup. When the mouse leave that control, I close the popup. The problem is that when the popup is open, and I move the mouse over the button, it tries to close and open several times (flickering the button):
<Window x:Class="HwndHostSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:local="clr-namespace:HwndHostSample" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" Title="MainWindow" Height="350" Width="525"><Grid><Grid.RowDefinitions><RowDefinition Height="*"/><RowDefinition Height="180"/></Grid.RowDefinitions><WindowsFormsHost Name="border" Grid.Row="1" ><wf:Panel AutoSize="True" BackColor="Blue" MouseEnter="Panel_MouseEnter" MouseLeave="Panel_MouseLeave"/></WindowsFormsHost><Popup IsOpen="False" Name="popup" PlacementTarget="{Binding ElementName=border}" Placement="Center" PopupAnimation="Fade" StaysOpen="True" AllowsTransparency="True"><Button Content="Test" Width="150" Height="80"/></Popup></Grid></Window>
private void Panel_MouseEnter(object sender, EventArgs e) { popup.IsOpen = true; } private void Panel_MouseLeave(object sender, EventArgs e) { if (!popup.IsMouseCaptured) popup.IsOpen = false; }
I even tried to handle if the popup has mouse captured, but that doesn't work either.
How can I stop the flickering?
Take a look at WPF FlashMessage
About.me