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 9201791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:06:14+00:00 2026-06-17T23:06:14+00:00

Is there a way to set an element in XAML to be hidden? When

  • 0

Is there a way to set an element in XAML to be hidden? When users click a New Game button I want a set of buttons (probably in a stack panel) to animate into view letting the user choose the difficulty level. I tried setting Visibility to Collapsed, but when I use one of the built-in Win8 animations such as EntranceThemeTransition or PopIn the collapsed element doesn’t show up. Changing the opacity to 0 and then trying to animate using one of these has the same effect.

  • 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-17T23:06:15+00:00Added an answer on June 17, 2026 at 11:06 pm

    The Visibility property works independently from Opacity. You need to set Visibility back to Visible before running a custom Opacity animation or the built in FadeInThemeAnimation.

    You can use the WinRT XAML Toolkit extensions to run a simple animation like this:

    myElement.Visibility = Visibility.Visible;
    myElement.FadeInCustom();
    

    The extension methods class from the XAML Toolkit:

    using System;
    using System.Threading.Tasks;
    using WinRTXamlToolkit.AwaitableUI;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Media.Animation;
    
    namespace WinRTXamlToolkit.Controls.Extensions
    {
        /// <summary>
        /// Extension methods and attached properties for UIElement class.
        /// </summary>
        public static class UIElementAnimationExtensions
        {
            #region AttachedFadeStoryboard
            /// <summary>
            /// AttachedFadeStoryboard Attached Dependency Property
            /// </summary>
            public static readonly DependencyProperty AttachedFadeStoryboardProperty =
                DependencyProperty.RegisterAttached(
                    "AttachedFadeStoryboard",
                    typeof(Storyboard),
                    typeof(UIElementAnimationExtensions),
                    new PropertyMetadata(null, OnAttachedFadeStoryboardChanged));
    
            /// <summary>
            /// Gets the AttachedFadeStoryboard property. This dependency property 
            /// indicates the currently running custom fade in/out storyboard.
            /// </summary>
            private static Storyboard GetAttachedFadeStoryboard(DependencyObject d)
            {
                return (Storyboard)d.GetValue(AttachedFadeStoryboardProperty);
            }
    
            /// <summary>
            /// Sets the AttachedFadeStoryboard property. This dependency property 
            /// indicates the currently running custom fade in/out storyboard.
            /// </summary>
            private static void SetAttachedFadeStoryboard(DependencyObject d, Storyboard value)
            {
                d.SetValue(AttachedFadeStoryboardProperty, value);
            }
    
            /// <summary>
            /// Handles changes to the AttachedFadeStoryboard property.
            /// </summary>
            /// <param name="d">
            /// The <see cref="DependencyObject"/> on which
            /// the property has changed value.
            /// </param>
            /// <param name="e">
            /// Event data that is issued by any event that
            /// tracks changes to the effective value of this property.
            /// </param>
            private static void OnAttachedFadeStoryboardChanged(
                DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                Storyboard oldAttachedFadeStoryboard = (Storyboard)e.OldValue;
                Storyboard newAttachedFadeStoryboard = (Storyboard)d.GetValue(AttachedFadeStoryboardProperty);
            }
            #endregion
    
            #region FadeIn()
            /// <summary>
            /// Fades the element in using the FadeInThemeAnimation.
            /// </summary>
            /// <remarks>
            /// Opacity property of the element is not affected.<br/>
            /// The duration of the visible animation itself is not affected by the duration parameter. It merely indicates how long the Storyboard will run.<br/>
            /// If FadeOutThemeAnimation was not used on the element before - nothing will happen.<br/>
            /// </remarks>
            /// <param name="element"></param>
            /// <param name="duration"></param>
            /// <returns></returns>
            public static async Task FadeIn(this UIElement element, TimeSpan? duration = null)
            {
                ((FrameworkElement)element).Visibility = Visibility.Visible;
                var fadeInStoryboard = new Storyboard();
                var fadeInAnimation = new FadeInThemeAnimation();
    
                if (duration != null)
                {
                    fadeInAnimation.Duration = duration.Value;
                }
    
                Storyboard.SetTarget(fadeInAnimation, element);
                fadeInStoryboard.Children.Add(fadeInAnimation);
                await fadeInStoryboard.BeginAsync();
            } 
            #endregion
    
            #region FadeOut()
            /// <summary>
            /// Fades the element out using the FadeOutThemeAnimation.
            /// </summary>
            /// <remarks>
            /// Opacity property of the element is not affected.<br/>
            /// The duration of the visible animation itself is not affected by the duration parameter. It merely indicates how long the Storyboard will run.<br/>
            /// If FadeOutThemeAnimation was already run before and FadeInThemeAnimation was not run after that - nothing will happen.<br/>
            /// </remarks>
            /// <param name="element"></param>
            /// <param name="duration"></param>
            /// <returns></returns>
            public static async Task FadeOut(this UIElement element, TimeSpan? duration = null)
            {
                var fadeOutStoryboard = new Storyboard();
                var fadeOutAnimation = new FadeOutThemeAnimation();
    
                if (duration != null)
                {
                    fadeOutAnimation.Duration = duration.Value;
                }
    
                Storyboard.SetTarget(fadeOutAnimation, element);
                fadeOutStoryboard.Children.Add(fadeOutAnimation);
                await fadeOutStoryboard.BeginAsync();
            } 
            #endregion
    
            #region FadeInCustom()
            /// <summary>
            /// Fades the element in using a custom DoubleAnimation of the Opacity property.
            /// </summary>
            /// <param name="element"></param>
            /// <param name="duration"></param>
            /// <param name="easingFunction"> </param>
            /// <returns></returns>
            public static async Task FadeInCustom(this UIElement element, TimeSpan? duration = null, EasingFunctionBase easingFunction = null, double targetOpacity = 1.0)
            {
                CleanUpPreviousFadeStoryboard(element);
    
                var fadeInStoryboard = new Storyboard();
                var fadeInAnimation = new DoubleAnimation();
    
                if (duration == null)
                    duration = TimeSpan.FromSeconds(0.4);
    
                fadeInAnimation.Duration = duration.Value;
                fadeInAnimation.To = targetOpacity;
                fadeInAnimation.EasingFunction = easingFunction;
    
                Storyboard.SetTarget(fadeInAnimation, element);
                Storyboard.SetTargetProperty(fadeInAnimation, "Opacity");
                fadeInStoryboard.Children.Add(fadeInAnimation);
                SetAttachedFadeStoryboard(element, fadeInStoryboard);
                await fadeInStoryboard.BeginAsync();
                element.Opacity = targetOpacity;
                fadeInStoryboard.Stop();
            }
            #endregion
    
            #region FadeOutCustom()
            /// <summary>
            /// Fades the element out using a custom DoubleAnimation of the Opacity property.
            /// </summary>
            /// <param name="element"></param>
            /// <param name="duration"></param>
            /// <param name="easingFunction"> </param>
            /// <returns></returns>
            public static async Task FadeOutCustom(this UIElement element, TimeSpan? duration = null, EasingFunctionBase easingFunction = null)
            {
                CleanUpPreviousFadeStoryboard(element); 
    
                var fadeOutStoryboard = new Storyboard();
                var fadeOutAnimation = new DoubleAnimation();
    
                if (duration == null)
                    duration = TimeSpan.FromSeconds(0.4);
    
                fadeOutAnimation.Duration = duration.Value;
                fadeOutAnimation.To = 0.0;
                fadeOutAnimation.EasingFunction = easingFunction;
    
                Storyboard.SetTarget(fadeOutAnimation, element);
                Storyboard.SetTargetProperty(fadeOutAnimation, "Opacity");
                fadeOutStoryboard.Children.Add(fadeOutAnimation);
                SetAttachedFadeStoryboard(element, fadeOutStoryboard);
                await fadeOutStoryboard.BeginAsync();
                element.Opacity = 0.0;
                fadeOutStoryboard.Stop();
            } 
            #endregion
    
            #region CleanUpPreviousFadeStoryboard()
            public static void CleanUpPreviousFadeStoryboard(this UIElement element)
            {
                var attachedFadeStoryboard = GetAttachedFadeStoryboard(element);
    
                if (attachedFadeStoryboard != null)
                {
                    attachedFadeStoryboard.Stop();
                }
            }
            #endregion
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way in CSS to set the width of any element to
Is there a way to set every element of a Javascript typed array (i.e.
Is there a way to set the bg color of an element in one
is there any way to set the link element <a to 100% width inside
Is there a way to set a CSS element (div in this case) to
Is there any way to set a background color for the HTML <area> element?
Is there a way to make a collapsible element/set in jQuery Mobile not inset?
Is there any way to set a jQuery event when some (any one) element
Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
Is there any way to set up a PendingIntent with the download manager? Or

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.