【发布时间】:2017-11-15 21:25:12
【问题描述】:
我已经使用了诸如此类的 Microsoft 文档和网站并取得了一些成功,但我无法实现我的目标。
我想要一个图像点击来启动故事板,图像点击来自一个网格视图内的对象实例。
<GridView ItemSource="{Binding"}>
<GridView.ItemTemplate>
<DataTempate>
<Grid>
<Grid.Resources>
<Storyboard>
<!-- storyboard code here no worries it works outside the data template-->
</Storyboard>
<Image Tapped="Image_Tapped" Source="assets/stuff/stuff.png">
</Image>
在 DataTemplate 中有一个图像,我希望点击该图像的事件来启动与该实例相关的情节提要。 Gridview.DataContext 来自 ObservableCollection<Player>。 Player 是我编写的一个类,它包含一些字符串和 int 属性并使用 INotifyPropertyChanged
我试过了
<Image>
<Image.Triggers>
<EventTrigger RoutedEvent="">
<!--this only works when the UIElement is loaded-->
我以为我正在使用 EventTrigger 到达某个地方,但我需要情节提要从点击图像或按钮单击或某种形式的用户输入开始。
我还尝试将情节提要移动到各种 xaml 位置并使用
this.Resources["MyStoryboard"]as Storyboard).Begin();
任何帮助想法都会很棒,谢谢。
【问题讨论】:
标签: c# xaml uwp storyboard