Tech Off Thread

5 posts

WPF bug animating Frame?

Back to Forum: Tech Off
  • User profile image

    I am trying to animate a Frame which has the Source property set to a URL, but nothing happens.

    I have distilled it down to the following, but still no luck, the Button content changes but the Frame has not faded out.

     public void ButtonClick(object sender, RoutedEventArgs args)
                DoubleAnimation animation = new DoubleAnimation();
                animation.From = 1.0;
                animation.To = 0.0;
                animation.Duration = new Duration(TimeSpan.FromSeconds(2));
                animation.AutoReverse = false;

                Storyboard storyboard = new Storyboard();
                Storyboard.SetTargetName(animation, frame1.Name);
                Storyboard.SetTargetProperty(animation, new PropertyPath(Frame.OpacityProperty));
                storyboard.Completed += new EventHandler(storyboardComplete);

            void storyboardComplete(object sender, EventArgs e)
                button1.Content = "Done";

    I can understand if Frame does not support this, but why make it possible to write the code if it just isn't going to work?

    On a related note, anybody any suggestions on applying Animations to WindowsHost controls? Or am I dreaming?

  • User profile image

    Try this:


  • User profile image

    Nope, no joy.

    The Begin method take the container though, so 'this' should be appropriate, it is the Window containing the Frame.

  • User profile image

    The animation worked when applied on other elements in a test project I made, including a Frame element with just a solid red background.  I think it's just a limitation of the Frame element when rendering HTML.  It uses the WebBrowser control which is just a wrapper around the MSHTML ActiveX control, I believe.

    Hmm, it might be fun to write a Web browser in WPF...

  • User profile image

    Frame element is wrapping window with handle, thus it can not have animated opacity. However, you can create VisualBrush over Frame and Animate it

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.