-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
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
- 1 view
-
The head of Microsoft's Windows team wants your thoughts about UX frameworks
By John Callaham,
- microsoft
- microsoft windows
- (and 8 more)
- 20 replies
- 6 views
-
Here's when and where you can watch Netflix DROP 01 global live stream
By Aditya Tiwari,
- 0 replies
- 3 views
-
Microsoft may soon ditch DirectUI and move to XAML, WinAppSDK on next-gen Windows 11
By hellowalkman,
- windows 11 gallery
- windows 11 ui
- (and 17 more)
- 20 replies
- 3 views
-
Microsoft MSIX Packaging Tool for Windows apps gets major update with bunch of new features
By hellowalkman,
- msix packaging tool
- msix
- (and 8 more)
- 0 replies
- 2 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);
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
Share on other sites
2 answers to this question
Recommended Posts