本文整理汇总了C#中System.Windows.Media.TranslateTransform.Animate方法的典型用法代码示例。如果您正苦于以下问题:C# TranslateTransform.Animate方法的具体用法?C# TranslateTransform.Animate怎么用?C# TranslateTransform.Animate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.TranslateTransform
的用法示例。
在下文中一共展示了TranslateTransform.Animate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToDoItemDeletedAction
private void ToDoItemDeletedAction(FrameworkElement deletedElement)
{
_deleteSound.Play();
var trans = deletedElement.GetHorizontalOffset().Transform;
trans.Animate(trans.X, -(deletedElement.ActualWidth + 50),
TranslateTransform.XProperty, 300, 0, new SineEase()
{
EasingMode = EasingMode.EaseOut
},
() =>
{
// find the model object that was deleted
ToDoItemViewModel deletedItem = deletedElement.DataContext as ToDoItemViewModel;
// determine how much we have to 'shuffle' up by
double elementOffset = -deletedElement.ActualHeight;
// find the items in view, and the location of the deleted item in this list
var itemsInView = _todoList.GetItemsInView().ToList();
var lastItem = itemsInView.Last();
int startTime = 0;
int deletedItemIndex = itemsInView.Select(i => i.DataContext)
.ToList().IndexOf(deletedItem);
// iterate over each item
foreach (FrameworkElement element in itemsInView.Skip(deletedItemIndex))
{
// for the last item, create an action that deletes the model object
// and re-renders the list
Action action = null;
if (element == lastItem)
{
action = () =>
{
// clone the list
_todoItems.Remove(deletedItem);
// re-populate our ObservableCollection
_todoItems.Reset();
};
}
// shuffle this item up
TranslateTransform elementTrans = new TranslateTransform();
element.RenderTransform = elementTrans;
elementTrans.Animate(0, elementOffset, TranslateTransform.YProperty, 200, startTime, null, action);
startTime += 10;
}
});
}