Tech Off Thread

5 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WPF bug animating Frame?

Back to Forum: Tech Off
  • User profile image
    Rossj

    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.Children.Add(animation);
                Storyboard.SetTargetName(animation, frame1.Name);
                Storyboard.SetTargetProperty(animation, new PropertyPath(Frame.OpacityProperty));
                storyboard.Completed += new EventHandler(storyboardComplete);
                storyboard.Begin(this);
            }

            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
    ninomk

    Try this:

    storyboard.Begin(frame1);

  • User profile image
    Rossj

    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
    JChung2006

    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
    tamir

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

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.