本文整理汇总了C#中System.Windows.Controls.ListBox.TranslatePoint方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.TranslatePoint方法的具体用法?C# ListBox.TranslatePoint怎么用?C# ListBox.TranslatePoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ListBox
的用法示例。
在下文中一共展示了ListBox.TranslatePoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Restore
private void Restore(ListBox menu)
{
menu.IsEnabled = false;
menu.Visibility = Visibility.Visible;
var breadcrumbItem = BreadcrumbContainer.Items.Count > 0
? (ListBoxItem)BreadcrumbContainer.Items[BreadcrumbContainer.Items.Count - 1]
: null;
Point
origin = new Point(0, 0),
menuPoint = menu.TranslatePoint(origin, this),
breadcrumbPoint = breadcrumbItem == null ? origin : breadcrumbItem.TranslatePoint(origin, this)
;
var duration = new Duration(TimeSpan.FromMilliseconds(300));
DoubleAnimation
posXAnimation = new DoubleAnimation { Duration = duration, From = breadcrumbPoint.X - menuPoint.X },
posYAnimation = new DoubleAnimation { Duration = duration, From = breadcrumbPoint.Y - menuPoint.Y },
scaleXAnimation = new DoubleAnimation { Duration = duration, From = 0.3 },
scaleYAnimation = new DoubleAnimation { Duration = duration, From = 0.3 },
opacityAnimation = new DoubleAnimation { Duration = duration, From = 0 }
;
var translateTransform = ((TransformGroup)menu.RenderTransform).Children[0];
var scaleTransform = ((TransformGroup)menu.RenderTransform).Children[1];
translateTransform.BeginAnimation(TranslateTransform.XProperty, posXAnimation);
translateTransform.BeginAnimation(TranslateTransform.YProperty, posYAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleXAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleYAnimation);
opacityAnimation.Completed += (object sender, EventArgs e) =>
{
menu.IsEnabled = true;
translateTransform.BeginAnimation(TranslateTransform.XProperty, null);
translateTransform.BeginAnimation(TranslateTransform.YProperty, null);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, null);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, null);
menu.BeginAnimation(OpacityProperty, null);
};
menu.BeginAnimation(OpacityProperty, opacityAnimation);
}