D.Loos
D.Loos

Reputation: 119

Continuum for UWP application

I have some questions about Continuum on UWP application.

  1. How can I know that Continuum connect to my Windows Phone? Now I check for it's DeviceType.Mobile and UserInteractionMode Mouse.

  2. How to do mouse right click in Continuum for show flyout? For example, I saw this in Microsoft Application.

Upvotes: 0

Views: 139

Answers (1)

user3922344
user3922344

Reputation:

Suppose that you are using the TextBox control, by default if you are using the TextBox control in the Desktop, it will show us a ContextMenu and fire the ContextMenuOpening event when we right click the TextBox, but if we are using the TextBox control in the Mobile, when we right click the TextBox, the ContextMenu will do not show and the ContextMenuOpening event will not fire as well. Because the ContextMenu like the "Paste" will show in the On-Screen keyboard.

If you want to show the ContextMenu when using the Continuum, you have two workarounds. One workaround is to click the "Shift+F10" in your physical keyboard, after that the ContextMenu should show and the ContextMenuOpening event should be fired. The others workaround is to handle the DoubleTapped event of the TextBox and show a new Flyout inside the event as following:

In the MainPage.xaml:

<TextBox Height="50" DoubleTapped="TextBox_DoubleTapped">
      <FlyoutBase.AttachedFlyout>
          <MenuFlyout>
              <MenuFlyoutItem x:Name="EditButton" Text="Some Command" />
              <MenuFlyoutItem x:Name="DeleteButton" Text="Some Command" />
          </MenuFlyout>
     </FlyoutBase.AttachedFlyout>
</TextBox>

In the MainPage.xaml.cs:

private void TextBox_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
    {
        FrameworkElement senderElement = sender as FrameworkElement;
        FlyoutBase flyoutBase = FlyoutBase.GetAttachedFlyout(senderElement);
        flyoutBase.ShowAt(senderElement);
    }

Upvotes: 1

Related Questions