0

ItemTemplateSelector のおかげで、異なるスタイルのアイテムが取り込まれた ListView があります。DataTemplate は、次のようにリソースとして app.xaml に配置されます。

<DataTemplate x:Key="FollowingOuterTemplate">
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
            <FlyoutBase.AttachedFlyout>
                <MenuFlyout>
                    <MenuFlyoutItem Text="Delete" />
                    <MenuFlyoutItem Text="Refresh" />
                    <MenuFlyoutItem Text="Share" />
                </MenuFlyout>
            </FlyoutBase.AttachedFlyout>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                <StackPanel Orientation="Vertical" Width="282">
                    <TextBlock Grid.Row="0" FontSize="33" Text="{Binding Pseudo}" Foreground="Gray" Height="46" Margin="0,0,-0.333,0"/>
                    <TextBlock Grid.Row="1" FontSize="20" Text="{Binding NomPrenom}" Foreground="#5bc5eb" Height="27" Margin="0,0,-0.333,0"/>
                    <TextBlock Grid.Row="2" FontSize="20" Text="Appuyez pour ne plus suivre" Foreground="#BCC6CC" Height="27" Margin="0,0,-0.333,0"/>
                </StackPanel>
                <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" Width="113">
                    <Image Name="StatutContact"  Height="43" Source="/Ressources/Images/checkedTests2.png" Stretch="Fill" Margin="0,20,0,0" Width="44" HorizontalAlignment="Center"/>
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </DataTemplate>

そこで、アイテムを保持しているときにFlyoutBase の添付メニューを表示したいと思います。ただし、DataTemplate は app.xaml にあり、そこにイベント ハンドラーを追加することは禁止されているため (app.xaml.cs はページを構築していないため、コンストラクターがありません)。FyloutBase メニューが接続されている StackPanel にHoldingイベント ハンドラーを追加したいと考えています。

誰でもそれを達成する方法を知っていますか?

4

1 に答える 1

0

本当にそれができないかどうかはわかりませんが、Shawn Kendrot は彼のブログで、問題を回避する Silverlight Toolkit の ContextMenuService の移植を提案しました。

于 2015-02-01T14:02:58.450 に答える