-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
Microsoft updates official lightweight Windows 11 Validation OS with DISM, WPF .NET upgrades
By hellowalkman,
- microsoft
- windows 11
- (and 9 more)
- 0 replies
- 0 views
-
- 13 replies
- 8 views
-
One UI animations to get better with the Samsung Galaxy S25 Ultra
By Sagar Naresh,
- samsung
- galaxy s25
- (and 5 more)
- 4 replies
- 10 views
-
- 1 reply
- 2,368 views
-
Behind-the-Scenes: North Korean animators secretly work on Amazon and HBO Max shows
By Fiza Ali,
- nick roy
- 38 north project
- (and 18 more)
- 0 replies
- 4 views
-
Question
James Rose
Hello gang,
I am back again with another WPF question.
I have a MainWindow and within that a collection of UserControls (menus). Last week I was given help on figuring out why the animation to move these controls from the bottom (hidden) to their correct position. (see first picture)
The code for doing this is here (and it works correctly, thanks Johnny)
The next step when the user navigates up is to hide the top menu (via an opacity animation) Here is the code I have created via Johnny's work and some research.
private static void Translate(FrameworkElement e)
{
try
{
TimeSpan duration = new TimeSpan(0, 0, 0, 3, 0);
var sb = new Storyboard();
TranslateTransform tt2 = new TranslateTransform();
e.RegisterName("MenuFade", tt2);
e.RenderTransform = tt2;
DoubleAnimation aniFade = new DoubleAnimation
{
From = 1.0,
To = 0.0,
Duration = new Duration(duration)
};
sb.Children.Add(aniFade);
Storyboard.SetTargetName(aniFade, "MenuFade");
Storyboard.SetTargetProperty(aniFade, new PropertyPath(BediaMenu.BMenu.OpacityProperty));
//storyboard.Begin(e);
e.Resources.Add("SB);
sb.Begin();
// Unregister Storyboard (Cleanup)
e.Resources.Remove("SB");
e.UnregisterName("MenuFade");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
LogEx objLog = new LogEx();
objLog.LogException(ex);
objLog = null;
}
}
[/CODE]
EDIT:
Here is the code that is called when the user navigates up
private void PageUp(Int16 Count)
{
try
{
foreach (UIElement element in this.BediaCanvas.Children)
{
if (element is Grid)
{
Grid grd = element as Grid;
foreach (UIElement mnuElement in grd.Children)
{
if (mnuElement is BediaMenu.BMenu)
{
BediaMenu.BMenu bMenu = mnuElement as BediaMenu.BMenu;
if (bMenu.Name != "Titlebar")
{
Translate(bMenu);
}
}
}
}
}
}
catch (Exception ex)
{
LogEx objLog = new LogEx();
objLog.LogException(ex);
objLog = null;
}
}
[/CODE]
Not only does it not fade out the menus but they all move to the top (see second image)
Any thoughts?
Link to comment
https://www.neowin.net/forum/topic/1053135-wpfc-opacity-animation/Share on other sites
2 answers to this question
Recommended Posts