locked
One Listview with ListViewItems having each a FlyOut Menu attached

    Question

  • Hello,

    I am writing an app using SwapChainPanel and XAML UI elements. One of these is a ListView that is declared as follows:

    <ListView x:Name="ListViewItems" Width="225" VerticalAlignment="Stretch" HorizontalAlignment="Right" Header="Markers" SelectionMode="Multiple" RightTapped="ListViewItems_RightTapped" IsItemClickEnabled="True" ItemClick="ListViewItems_ItemClick" SelectionChanged="ListViewItems_SelectionChanged_1" IsSwipeEnabled="True">

    To every ListViewItem that is part of the ListView, I want to attach a FlyOut like this:

    FlyoutBase.AttachedFlyout="{StaticResource FlyoutBase1}"

    Actually, I am using an item template like this:

    <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Width="292" Height="80">
    ....

    So, my question is, how to attach this FlyOut by XAML or programmatically to every single data bound ListViewItem; yet I only know how to attach the FlyOut to the whole ListView. This is not my intention, because the FlyOuts attached to the whole control are always positioned on the same location and not beneath the clicked ListViewItem. Further on, I want to change the content of the FlyOut dependent on which ListViewItem was clicked.

    Thanks for your help in advance!

     


    Saturday, January 4, 2014 7:12 PM

Answers

  • Hi MarkusDotNet,

    You could do it like this:

    <ListView.ItemTemplate>
                    <DataTemplate >
                        <StackPanel>
                            <TextBlock Text="{Binding}Tapped="TextBlock_Tapped"">
                                <FlyoutBase.AttachedFlyout>
                                     <Flyout>
                                          <TextBox x:Name="MyTextBox" Text="You can edit this text by tapping it."/>
                                      </Flyout>
                                 </FlyoutBase.AttachedFlyout>
                                  ........

    You could refer this article:

    http://msdn.microsoft.com/en-us/library/windows/apps/bg182878.aspx#Flyout

    I hope it is helpful!

    Regards!

    Xiaoliang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, January 6, 2014 7:52 AM
    Moderator