3

I'm want to use Interaction.Triggers inside a ContentPresenter, but for some reasons, the event doesn't get fired. If I change ContentPresenter against ContentControl, the event binding works as expected.

    <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>

and the ContentControl creation in code behind:

var content = new ContentPresenter()
{
    Content = this,
    ContentTemplate = Application.Current.Resources["MapPictureTemplate"] as DataTemplate
};
Philipp
  • 15,377
  • 4
  • 35
  • 52

0 Answers0