C# 如何在通用Windows平台中使用行为?
我正在尝试为我的纸牌游戏添加行为,但不知道如何正确使用它们-将行为放置在何处等。 我有一个卡片列表框(卡片是从图像中加载的),我想在点击时向上移动卡片,再次点击时向下移动卡片。 有谁能给我推荐如何在UWP应用程序中使用行为的指南,或者给我一个代码示例(不起作用:())C# 如何在通用Windows平台中使用行为?,c#,xaml,uwp,blend,C#,Xaml,Uwp,Blend,我正在尝试为我的纸牌游戏添加行为,但不知道如何正确使用它们-将行为放置在何处等。 我有一个卡片列表框(卡片是从图像中加载的),我想在点击时向上移动卡片,再次点击时向下移动卡片。 有谁能给我推荐如何在UWP应用程序中使用行为的指南,或者给我一个代码示例(不起作用:()) 我不理解“点击时上移卡片,再次点击时下移”,您想将图像从何处移动到何处?上移到何处,下移到何处?尝试将您的替换为ListView的数据模板“单击时将卡向上移动,再次单击时将卡向下移动”,是否要将图像从何处移动到何处?向上移动到
我不理解“点击时上移卡片,再次点击时下移”,您想将图像从何处移动到何处?上移到何处,下移到何处?尝试将您的
替换为ListView
的数据模板“单击时将卡向上移动,再次单击时将卡向下移动”,是否要将图像从何处移动到何处?向上移动到何处,向下移动到何处?尝试将
替换到列表视图的数据模板中。
<Page.Resources>
<Storyboard x:Key="storyboard1" >
</Storyboard>
</Page.Resources>
<ListView x:Name="list" Grid.Row="0" Grid.Column="0" Padding="50,0" ScrollViewer.VerticalScrollBarVisibility="Disabled" VerticalAlignment="Center" HorizontalContentAlignment="Stretch" ItemClick="ListView_ItemClick" >
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Margin" Value="0,0,-70,0"></Setter>
<Setter Property="MaxHeight" Value="100"></Setter>
<Setter Property="MaxWidth" Value="68"></Setter>
<Setter Property="Padding" Value="0,0,0,0"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<ListViewItemPresenter>
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="GotFocus">
<media:ControlStoryboardAction Storyboard="{StaticResource storyboard1}">
</media:ControlStoryboardAction>
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</ListViewItemPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<ListViewItem>
</ListViewItem>
<Image x:Name="One" MaxWidth="68" Height="100" >
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior>
<media:ControlStoryboardAction Storyboard="{StaticResource storyboard1}">
</media:ControlStoryboardAction>
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Image>
<Image x:Name="Two" MaxWidth="68" Height="100" />
<Image x:Name="Three" MaxWidth="68" Height="100" />
</ListView>