我想在Interaction.Triggers
内使用ContentPresenter
,但由于某些原因,该事件不会被解雇。
如果我针对ContentControl更改ContentPresenter,则事件绑定将按预期工作。
<DataTemplate x:Key="MapPictureTemplate">
<Grid Width="80" Height="80" x:Name="Grid">
<Border
Background="{Binding Thumbnail, Converter={StaticResource StreamToImageBrushConverter}}"
CornerRadius="40">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap">
<i:InvokeCommandAction Command="{Binding Source={StaticResource Locator}, Path=Main.ImageTappedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Border>
</Grid>
</DataTemplate>
并在代码后面创建ContentControl:
var content = new ContentPresenter()
{
Content = this,
ContentTemplate = Application.Current.Resources["MapPictureTemplate"] as DataTemplate
};