我有ItemsControl
我绑定到ObservableCollection
在我的视图模型上,我只是插入对象并弹出到UI
我想展示转型。例如,我希望此项目淡入,以便用户可视地注册此更改,假设它在1秒内发生。
我应该寻找什么?它是如何在WPF中完成的?
编辑:
我想我需要某种动画,但我正在寻找的是没有编码的简单。简单的XAML实现,是内置的吗?我尝试了TranslateTransform
和其他选择,但它没有做任何事情。
<ItemsControl ItemsSource="{Binding Source={StaticResource TrucksSource}}">
<ItemsControl.RenderTransform>
<TranslateTransform />
</ItemsControl.RenderTransform>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding TruckId}" Background="Aqua"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
答案 0 :(得分:0)
阅读本文:http://msdn.microsoft.com/en-us/library/ms750596.aspx
您需要动画转换(上一章)并将不透明度值从1.0更改为0.0
答案 1 :(得分:0)
对于淡入,您可以对EventTrigger
Loaded
事件使用ContentPresenters
<ItemsControl ItemsSource="{Binding Source={StaticResource TrucksSource}}">
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard Storyboard.TargetProperty="Opacity">
<DoubleAnimation From="0.0"
To="1.0"
Duration="00:00:01"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding TruckId}" Background="Aqua"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>