Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Window messages not firing while popup window animation is running
    primarykey
    data
    text
    <p>I have created a little Popup window in WPF, which shows and hides with a 500 millisecond fade-animation.</p> <p>The Popup is shown when the PreviewMouseUp of a TextBox control is fired, and hidden when the focus of the TextBox is lost.</p> <p>The problem is that if I have two of these TextBoxes, the animation of the Popup-window seems to block all Window Messages sent to the main window while the animation is going. The PreviewMouseUp of the second TextBox is fired only right after the animation of the first TextBox's Popup is complete.</p> <p>Is there a way to make the fade-animation of my Popup Window NOT to block Window Messages while the animation is running?</p> <p>Example XAML file:</p> <pre><code> &lt;Window x:Class="WpfApplication4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"&gt; &lt;Grid&gt; &lt;TextBox HorizontalAlignment="Left" Height="23" Margin="22,26,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" PreviewMouseUp="TextBox_PreviewMouseUp_1" LostFocus="TextBox_LostFocus_1"/&gt; &lt;TextBox HorizontalAlignment="Left" Height="23" Margin="22,54,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" PreviewMouseUp="TextBox_PreviewMouseUp_1" LostFocus="TextBox_LostFocus_1"/&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Example Code file:</p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApplication4 { /// &lt;summary&gt; /// Interaction logic for MainWindow.xaml /// &lt;/summary&gt; public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void TextBox_PreviewMouseUp_1(object sender, MouseButtonEventArgs e) { Popup p = new Popup(); p.Width = 100; p.Height = 100; p.Placement = PlacementMode.Left; p.PlacementTarget = (TextBox)sender; p.Child = new Border(); p.IsOpen = true; ((TextBox)sender).Tag = p; } private void TextBox_LostFocus_1(object sender, RoutedEventArgs e) { Popup p = (Popup)((TextBox)sender).Tag; DoubleAnimation anim = new DoubleAnimation(100, 0, new Duration(new TimeSpan(0, 0, 1))); p.BeginAnimation(WidthProperty, anim); } } } </code></pre> <p>If you click quickly both textboxes, you notice that the other Popup won't appear (and the textbox doesn't get focus) while the animation is running. </p> <p>What I have found so far, it seems like if the animation is really intensive (high framefrate), the window messages are blocked until the animation is complete. If I set the application framerate to lower value, like 30FPS, then the problem goes away. But this is not an option for me because I wan't the animations to be as smooth as possible.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload