【发布时间】:2020-09-24 12:52:12
【问题描述】:
我有一个结合了许多数据模板的资源字典。我将此资源字典作为ResourceDictionary.MergedDictionaries 包含在我的Page.Resources 中。我的数据模板之一是ListView,虽然项目源和项目点击工作正常,但在数据模板中设置的ListViewItem 上的单独按钮没有调用我的点击方法。我不确定是否正确设置。
这个点击方法是在类后面的代码中定义的,它定义了页面 Xaml,包括资源字典并使用我的 ListViewItems 的数据模板。
-
字典
- DataTemplates.xaml Click="MyPages_ClickMethod"
-
页面
- MyPage.xaml
- MyPage.xaml.cs MyPages_ClickMethod()
这是我在数据模板中设置按钮的方式:
<Button Tag="{Binding id}" Click="MultiShareSelectFileButton_Click" Background="Transparent" Visibility="{Binding multiShareSelected, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=Inverted, Mode=OneWay}">
<Image Width="27" Source="ms-appx:///Assets/sharePlusIcon@2x.png" VerticalAlignment="Center" HorizontalAlignment="Center">
</Image>
</Button>
不使用 ICommand 是否可以做到这一点?
类似:Click="{x:Bind Path=pages:ProductPage.MultiShareSelectFileButton_Click}",但这是在抱怨 MultiShareSelectFileButton_Click 应该是静态的
【问题讨论】: