0

我对 UWP 应用程序上的 Continuum 有一些疑问。

  1. 我如何知道 Continuum 连接到我的 Windows Phone?现在我检查它DeviceType.Mobile和 UserInteractionMode鼠标。

  2. 如何在 Continuum 中单击鼠标右键以显示弹出窗口?例如,我在 Microsoft 应用程序中看到了这一点。

4

1 回答 1

1

假设您使用的是 TextBox 控件,默认情况下,如果您在桌面中使用 TextBox 控件,它会在我们右键单击 TextBox 时向我们显示 ContextMenu 并触发 ContextMenuOpening 事件,但如果我们在桌面中使用 TextBox 控件移动设备,当我们右键单击 TextBox 时,不会显示 ContextMenu,也不会触发 ContextMenuOpening 事件。因为像“粘贴”这样的 ContextMenu 将显示在屏幕键盘中。

如果您想在使用 Continuum 时显示 ContextMenu,您有两种解决方法。一种解决方法是单击物理键盘中的“Shift+F10”,然后应显示 ContextMenu 并触发 ContextMenuOpening 事件。其他解决方法是处理 TextBox 的 DoubleTapped 事件并在事件中显示一个新的 Flyout,如下所示:

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

在 MainPage.xaml.cs 中:

private void TextBox_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
    {
        FrameworkElement senderElement = sender as FrameworkElement;
        FlyoutBase flyoutBase = FlyoutBase.GetAttachedFlyout(senderElement);
        flyoutBase.ShowAt(senderElement);
    }
于 2016-06-29T09:22:37.637 回答