事件绑定在ContentPresenter中不起作用

时间:2014-03-08 10:35:07

标签: c# wpf xaml events windows-phone-8

我想在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
};

0 个答案:

没有答案