本文整理汇总了C#中System.Windows.Window.EndInit方法的典型用法代码示例。如果您正苦于以下问题:C# Window.EndInit方法的具体用法?C# Window.EndInit怎么用?C# Window.EndInit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.EndInit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: animateWindowHeight
/// <summary>
/// Animates the window's height
/// </summary>
/// <param name="window">The window to animate</param>
/// <param name="height">The height to animate the window to</param>
/// <param name="duration">The duration for the animation</param>
/// <param name="callback">An optional callback to be executed when the animation finishes</param>
private void animateWindowHeight(Window window, double height, double duration, Action callback = null)
{
window.BeginInit();
window.Dispatcher.BeginInvoke((Action)(() =>
{
DoubleAnimation windowAnimation = new DoubleAnimation();
windowAnimation.Duration = new Duration(TimeSpan.FromSeconds(duration));
windowAnimation.From = window.Height;
windowAnimation.To = height;
windowAnimation.FillBehavior = FillBehavior.HoldEnd;
//If a callback is passed, execute it using a lambda expression
if (callback != null)
{
windowAnimation.Completed += (s, e) => callback();
}
window.BeginAnimation(Window.HeightProperty, windowAnimation);
}), null);
window.EndInit();
}