C# 通过转换绑定到ObservableCollection
我有ItemsControl,绑定到ObservaleCollection 在我的视图模型上,我只需插入对象,它就会弹出到UI上 我想展示我的转变。例如,我希望此项淡入,以便用户以可视方式注册此更改,假设它在1秒内发生 我应该找什么?在WPF中是如何完成的 编辑: 我想我需要一些动画,但我要找的是一些没有编码的简单的东西。普通的XAML实现,有内置的东西吗?我尝试了TranslateTransform和其他选择,但没有任何效果C# 通过转换绑定到ObservableCollection,c#,wpf,xaml,C#,Wpf,Xaml,我有ItemsControl,绑定到ObservaleCollection 在我的视图模型上,我只需插入对象,它就会弹出到UI上 我想展示我的转变。例如,我希望此项淡入,以便用户以可视方式注册此更改,假设它在1秒内发生 我应该找什么?在WPF中是如何完成的 编辑: 我想我需要一些动画,但我要找的是一些没有编码的简单的东西。普通的XAML实现,有内置的东西吗?我尝试了TranslateTransform和其他选择,但没有任何效果 <ItemsControl ItemsSource="{Bin
<ItemsControl ItemsSource="{Binding Source={StaticResource TrucksSource}}">
<ItemsControl.RenderTransform>
<TranslateTransform />
</ItemsControl.RenderTransform>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding TruckId}" Background="Aqua"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
请阅读以下内容:
您需要在上一章设置变换动画,并将“不透明度”值从1.0更改为0.0。对于淡入,您可以对ContentPresenters加载的事件使用EventTrigger
<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>