在 XAML 中将动画绑定到 ListViewItem
我想为新创建的 ListViewItem 分配一个动画。就像淡入或淡出一样。 我有这个 XAML 代码:
<ListView Height="320" HorizontalAlignment="Left" Margin="630,0,0,0" Name="listView1" VerticalAlignment="Top" Width="222" ItemsSource="{Binding}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Name="mainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="150"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.Resources>
</Grid.Resources>
<Image Name="img" Source="{Binding AvatarSource}" Width="32" Margin="8"></Image>
<Image Source="{Binding IconSource}" Width="16" Margin="0,-28,32,0"></Image>
<TextBlock Grid.Column="1" Margin="0,8,0,0" TextWrapping="Wrap">
<Run Text="{Binding Name}" FontWeight="Bold"></Run>
<LineBreak/>
<Run Text="{Binding StatusText}"></Run>
</TextBlock>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
有没有办法像 jQuery 一样以任何方式访问: $('#listViewItemId').fadeIn();
我可以将 listView1.ItemsSource 绑定回某些可访问的表单,在其中我将看到其中的所有控件吗?而不是操纵它们?
我也不想在 C# 中手动执行此操作,但如果使用 ItemTemplate 无法完成此操作,我无论如何都会执行此操作。
我是 XAML 新手,找不到任何好的资源来以正确的方式学习 C# 的 XAML。
I would like to assign an animation to newly created ListViewItem. Like FadeIn or FadeOut.
I have this XAML code:
<ListView Height="320" HorizontalAlignment="Left" Margin="630,0,0,0" Name="listView1" VerticalAlignment="Top" Width="222" ItemsSource="{Binding}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Name="mainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="150"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.Resources>
</Grid.Resources>
<Image Name="img" Source="{Binding AvatarSource}" Width="32" Margin="8"></Image>
<Image Source="{Binding IconSource}" Width="16" Margin="0,-28,32,0"></Image>
<TextBlock Grid.Column="1" Margin="0,8,0,0" TextWrapping="Wrap">
<Run Text="{Binding Name}" FontWeight="Bold"></Run>
<LineBreak/>
<Run Text="{Binding StatusText}"></Run>
</TextBlock>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Is there a way to access any way like in jQuery: $('#listViewItemId').fadeIn();
Can I bind back listView1.ItemsSource to some accessible form in which I will see all Controls that are inside it? And than manipulate them?
I also would like to have no to do it manually in C#, but if this is impossible to accomplish using ItemTemplate I will do it anyway.
I am new to XAML and I couldn't find any good source to learn XAML with C# in proper way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面我发布了最简单的代码和 XAML 来实现你想要的。从那里开始,让它在您自己的应用程序中工作。
祝你好运!
Below I posted the most simple code and XAML that achieves what you want. Go from there to make it work in your own application.
Good Luck!