Click here to Skip to main content
11,637,662 members (70,487 online)
Click here to Skip to main content

WPF: Animate Visibility Property - Update

, 13 Apr 2010 Ms-PL 10.9K 10
Rate this:
Please Sign up or sign in to vote.
Back in this post I showed you how you can easily add a fade-in / fade-out effect to a UIElement that changes its Visibility property, using a simple attached property.Some people encountered a problem using this property when they bind the UIElement to a model which initially hides the control. Sin

Back in this post I showed you how you can easily add a fade-in / fade-out effect to a UIElement that changes its Visibility property, using a simple attached property.

Some people encountered a problem using this property when they bind the UIElement to a model which initially hides the control. Since the default value of the Visibility property is Visible, using the attached property created an unwanted fade-out animation when the application started.

To fix this issue I added another attached property that allows the user to skip the first animation.

Also, I’ve fixed a minor issue with the double animation of the opacity.

For completion, I bring here the full updated source. For more details on how the animation works, check the original post.

That’s it for now, Arik Poznanski.

Appendix A – Updated Source Code for VisibilityAnimation class

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Animation;

namespace WPF.Common
{
    /// <span class="code-SummaryComment"><summary>
</span>

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Arik Poznanski
Software Developer (Senior) Verint
Israel Israel
Arik Poznanski is a senior software developer at Verint. He completed two B.Sc. degrees in Mathematics & Computer Science, summa cum laude, from the Technion in Israel.

Arik has extensive knowledge and experience in many Microsoft technologies, including .NET with C#, WPF, Silverlight, WinForms, Interop, COM/ATL programming, C++ Win32 programming and reverse engineering (assembly, IL).

You may also be interested in...

Comments and Discussions

 
BugThis code give me an error Pin
Member 1104505229-Aug-14 0:03
memberMember 1104505229-Aug-14 0:03 
GeneralMemory leak Pin
schlaup2-Jun-11 4:27
memberschlaup2-Jun-11 4:27 
GeneralRe: Memory leak Pin
Arik Poznanski3-Jun-11 11:29
mvpArik Poznanski3-Jun-11 11:29 
Thanks for the heads up.
Arik Poznanski

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150728.1 | Last Updated 13 Apr 2010
Article Copyright 2010 by Arik Poznanski
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid