Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>WPF makes this absolutely trivial: It would proably take ten minutes or less. Here are the steps:</p> <ol> <li>Create a Window, set AllowsTransparency="true" and add a Grid to it</li> <li>Set the Grid's RenderTransform to a ScaleTransform with origin of 0,1</li> <li>Create an animation on the grid that animates the ScaleX 0 to 1 then later animates the Opacity from 1 to 0</li> <li>In the constructor calculate Window.Top and Window.Left to place the window in the lower right-hand corner of the screen.</li> </ol> <p>That's all there is to it.</p> <p>Using Expression Blend it took about 8 minutes me to generate the following working code:</p> <pre><code>&lt;Window x:Class="NotificationWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Notification Popup" Width="300" SizeToContent="Height" WindowStyle="None" AllowsTransparency="True" Background="Transparent"&gt; &lt;Grid RenderTransformOrigin="0,1" &gt; &lt;!-- Notification area --&gt; &lt;Border BorderThickness="1" Background="Beige" BorderBrush="Black" CornerRadius="10"&gt; &lt;StackPanel Margin="20"&gt; &lt;TextBlock TextWrapping="Wrap" Margin="5"&gt; &lt;Bold&gt;Notification data&lt;/Bold&gt;&lt;LineBreak /&gt;&lt;LineBreak /&gt; Something just happened and you are being notified of it. &lt;/TextBlock&gt; &lt;CheckBox Content="Checkable" Margin="5 5 0 5" /&gt; &lt;Button Content="Clickable" HorizontalAlignment="Center" /&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;!-- Animation --&gt; &lt;Grid.Triggers&gt; &lt;EventTrigger RoutedEvent="FrameworkElement.Loaded"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"&gt; &lt;SplineDoubleKeyFrame KeyTime="0:0:0" Value="0"/&gt; &lt;SplineDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"&gt; &lt;SplineDoubleKeyFrame KeyTime="0:0:2" Value="1"/&gt; &lt;SplineDoubleKeyFrame KeyTime="0:0:4" Value="0"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/Grid.Triggers&gt; &lt;Grid.RenderTransform&gt; &lt;ScaleTransform ScaleY="1" /&gt; &lt;/Grid.RenderTransform&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>With code behind:</p> <pre><code>using System; using System.Windows; using System.Windows.Threading; public partial class NotificationWindow { public NotificationWindow() { InitializeComponent(); Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =&gt; { var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea; var transform = PresentationSource.FromVisual(this).CompositionTarget.TransformFromDevice; var corner = transform.Transform(new Point(workingArea.Right, workingArea.Bottom)); this.Left = corner.X - this.ActualWidth - 100; this.Top = corner.Y - this.ActualHeight; })); } } </code></pre> <p>Since WPF is one of the regular .NET libraries, the answer is yes, it <em>is</em> possible to accomplish this with the "regular .NET libraries".</p> <p>If you're asking if there is a way to do this without using WPF the answer is still yes, but it is extremely complex and will take more like 5 days than 5 minutes.</p>
 

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