Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:43:52+00:00 2026-06-04T20:43:52+00:00

I have been trying to create a notification window, but I’m struggling to figure

  • 0

I have been trying to create a notification window, but I’m struggling to figure out why this opacity shift is not happening when I run it. Instead the window will hold for a second then close without any visible changes. All my other attempts via other methods have failed too, so it must be some property I am missing. Thanks for any help!

    public void RunForm(string error, MessageBoxIcon icon, int duration)
    {
        lblMessage.Text = error;
        Icon i = ToSystemIcon(icon);
        if (i != null)
        {
            BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(i.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            imgIcon.Source = bs;
        }
        this.WindowStartupLocation = WindowStartupLocation.Manual;
        this.Show();
        this.Left = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right - this.RestoreBounds.Width - 20;
        this.Top = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Bottom - this.RestoreBounds.Height - 20;
        while (this.Opacity > 0)
        {
            this.Opacity -= 0.05;
            Thread.Sleep(50);
        }
        this.Close();
    }


<Window Width="225" Height="140" VerticalContentAlignment="Center" HorizontalAlignment="Center" ShowActivated="True" ShowInTaskbar="False"
ResizeMode="NoResize" Grid.IsSharedSizeScope="False" SizeToContent="Height" WindowStyle="None" BorderBrush="Gray" 
BorderThickness="1.5" Background="White" Topmost="True" AllowsTransparency="True" Opacity="1">
<Grid Height="Auto" Name="grdNotificationBox" >
    <Image Margin="12,12,0,0" Name="imgIcon" Stretch="Fill" HorizontalAlignment="Left" Width="32" Height="29" VerticalAlignment="Top" />
    <TextBlock Name="lblMessage" TextWrapping="Wrap" Margin="57,11,17,11"></TextBlock>
</Grid>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:43:54+00:00Added an answer on June 4, 2026 at 8:43 pm

    This can’t work:
    The complete WPF handling is done in one single thread (technically two but not important). you change the opacity and directly let the ui thread sleep, change it again and send it back to sleep. The ui thread never got any time to process what you did. Even removing the sleep would not help, because than it would be much to fast, and the ui thread could not handle any requests aswell. Its important to understand that your code and WPFs handling is done in the same thread, the longer you need, the less time WPF got and vice versa.

    To solve it you need to use animations. They are exactly for these kind of thing. Checkout this thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to create a directory in /sdcard programmatically, but it's not
I have been trying to create a new google custom search engine, but when
I have been trying to create a web service out some python scripts, and
I have been trying to create a code like this: If you show 'us.gif'
I have been trying to create a torrent site but I'm stuck with the
I have been trying to create a deque in Java, but I get a
I have been trying to create a ListView which I can sort using drag
I have been trying to create a menu panel with jQuery that can be
I have been trying to create a simple program with Python which uses OpenCV
I have been trying to create an observable tweeter feed using tweetsharp with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.