locked
[UWP][C#]How to open the popup in pointer curent position in uwp RRS feed

  • Question

  • Hi,

    In my requirement how to open the popup in pointer current position when right tapped in uwp.

    Can you please provide the example

     private void SfTabItem_RightTapped(object sender, RightTappedRoutedEventArgs e)
            {
                 Part_Tabitem.Part_ContextMenu.IsOpen = true;
            }
    How to implement above code


    • Edited by Barry Wang Wednesday, July 27, 2016 8:14 AM title tag
    Tuesday, July 26, 2016 6:26 PM

Answers

  • Hi Ashok,

    Here is a demo I made.Maybe this is what you what:

    The Xaml part:

    <Page
       x:Class="Popup1.MainPage"
        xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
        xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
        xmlns:local="using:Popup1"
        xmlns:d=http://schemas.microsoft.com/expression/blend/2008
        xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
        mc:Ignorable="d">
       <Page.Resources>
            <MenuFlyout x:Name="menuflyout" x:Key="DeclarativeAttachedFlyout2">
                <MenuFlyoutItem Text="b1" ></MenuFlyoutItem>
                <MenuFlyoutItem Text="b2" ></MenuFlyoutItem>
                <MenuFlyoutItem Text="b3" ></MenuFlyoutItem>
                <MenuFlyoutItem Text="b4" ></MenuFlyoutItem>
            </MenuFlyout>
        </Page.Resources>
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <Button Name="btn1" Content="Click me" RightTapped="Button_RightTapped_1"/>
        </Grid>
    </Page>
    


    The code behind:

    namespace Popup1
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
            }
            private void Button_RightTapped_1(object sender, RightTappedRoutedEventArgs e)
            {
                menuflyout.ShowAt(btn1);
            }
        }
    }
    

    Please notice that I don't know which kind of "popup" is what you want. I only see that you want to open a contextmenu, which is a desktop scenario. If this is not what you want please share us more details.

    Best regards,

    Barry


    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.

    • Proposed as answer by Barry Wang Wednesday, August 3, 2016 10:11 AM
    • Marked as answer by Barry Wang Thursday, August 4, 2016 10:36 AM
    Wednesday, July 27, 2016 11:07 AM