0

I have a ListView populated by items having a different style thanks to an ItemTemplateSelector. The DataTemplates are placed in app.xaml as ressources like the following:

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

So now I would like to show the FlyoutBase attached menu when I'm holding an Item. But as the DataTemplate is in app.xaml and it's forbidden to add event handler there (app.xaml.cs is not having any constructor as it's not constructing pages). I would like to add a Holding event handler to the StackPanel that the FyloutBase Menu is attached to.

Anyone knows how to achieve that ?

Hubert Solecki
  • 2,611
  • 5
  • 31
  • 63

1 Answers1

0

Not sure if you really just cannot do that, but Shawn Kendrot proposed a port of the Silverlight Toolkit's ContextMenuService that gets around your problem on his Blog.

Kai Brummund
  • 3,538
  • 3
  • 23
  • 33