ModalBackground: fade out instead of pop away

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    15 posts
    Member since:
    Jul 2012

    Posted 12 Aug 2010 Link to this post

    I would like to have the modal background fade away instead of "pop" away when the modal window is closed. I created a storyboard with a color animation, and tried running it on the Closed event, as well as in an overridden OnClosed method, but no go.

    How can I do this? Code below:



    Main page has just a button that creates a new instance of my "modalDialog" and then runs a .ShowDialog() on it.

    RadWindow XAML:

    <Telerik:RadWindow x:Class="SilverlightApplication2.modalPopup"
        Width="700" Height="700">
            <SolidColorBrush x:Name="Brush1" Color="#AA00FF00" />
            <Storyboard x:Name="StoryBoard1">
            <Storyboard x:Name="StoryBoard2">
        <Grid x:Name="LayoutRoot" Background="White">
            <Path x:Name="path" Fill="{StaticResource Brush1}" Stretch="Fill" Stroke="Black" Margin="117.5,53.5,238.5,224.5" UseLayoutRounding="False" Data="M118,54 L401,119 L234,255 z"/>

    RadWindow Code Behind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls;
    namespace SilverlightApplication2
        public partial class modalPopup : RadWindow
            WindowClosedEventArgs _args;
            public modalPopup()
                StoryBoard1.Completed += new EventHandler(StoryBoard1_Completed);
                this.Closed += new EventHandler<WindowClosedEventArgs>(modalPopup_Closed);
                SolidColorBrush br = (SolidColorBrush)this.Resources["Brush1"];
                this.ModalBackground = br;
                // Below so can test storyboards on init and prove that they are "good" storyboards
                // (ie they change the desired properties in the desired way)
            protected override void OnClosed(WindowClosedEventArgs args)
                _args = args;
            void StoryBoard1_Completed(object sender, EventArgs e)
            // Tried running the storyboard on this.Closed event. Didn't work
            void modalPopup_Closed(object sender, WindowClosedEventArgs e)

  2. Pana
    Pana avatar
    748 posts

    Posted 18 Aug 2010 Link to this post

    Hi Jonathan,

    The animation works just fine. if you close and open the dialog the second time you see the changed / changing color.

    The OnClosed is invoked when the window's closing animation is complete. At that time the window is detached from the visual tree or collapsed so it is invisible. You can use the PreviewClosing instead. You can attached an event handler for that event of the window in the constructor, handle the event and raise it when the storyboard is over.

    Sincerely yours,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top