0

我正在开发一个 Windows 手机应用程序,我需要选择 Ipad 文本之类的菜单(剪切、复制、粘贴),还需要一些自定义菜单。当我在 windows phone 中选择文本时,只有一个选项复制文本可见。

建议我解决我的问题。

谢谢

编辑

<Border BorderThickness="3" Padding="6">
    <toolkit:GestureService.GestureListener>
        <toolkit:GestureListener Tap="GestureListener_Tap" />
    </toolkit:GestureService.GestureListener>
    <toolkit:ContextMenuService.ContextMenu>
        <toolkit:ContextMenu>
            <toolkit:MenuItem Header="item1" Click="Item1_Click" />
            <toolkit:MenuItem Header="item2" Click="Item2_Click" />
            <toolkit:MenuItem Header="item3" Click="Item3_Click" />
        </toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
    <TextBlock Text="Tap" />
</Border>

private void GestureListener_Tap(object sender, GestureEventArgs e)
{
    Border border = sender as Border;
    ContextMenu contextMenu = ContextMenuService.GetContextMenu(border);
    if (contextMenu.Parent == null)
    {
        contextMenu.IsOpen = true;
    }
}

我已经使用了此代码,但它会生成一个上下文菜单,如我不需要的列表项我需要一个圆角图像图标,如复制和粘贴,或者它想要 ipad 或 iphone 选择文本菜单。

我想要菜单

文本选择

4

1 回答 1

0

在此处查看我的问题和答案

然后像下面的代码一样添加手势事件列表器还请注意,您必须包含 Microsoft.Phone.Controls.Toolkit 参考。

GestureListener listener = new GestureListener();
        listener.Hold += (sender, args) =>
        {
            // some logic here
            textSelectionMenu.Tag = args;
            textSelectionMenu.SelectedItem = null;
            textSelectionMenuPopup.IsOpen = true;
            activePopup = textSelectionMenuPopup;
            textSelectionMenu.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Size selectionMenuSize = textSelectionMenu.DesiredSize;
            System.Windows.Point pt = args.GetPosition(textSelectionMenu);
            double offsetX = 50;
            double offsetY = pt.Y;

            // Finally, make sure it's on the screen
            //offsetX = Math.Max(0, Math.Min(offsetX, selectionMenuSize.Width));
            //offsetY = Math.Max(0, Math.Min(offsetY, selectionMenuSize.Height));

            textSelectionMenuPopup.HorizontalOffset = offsetX;
            textSelectionMenuPopup.VerticalOffset = offsetY;
        };
        this.Browser.SetValue(GestureService.GestureListenerProperty, listener);
于 2012-12-07T11:27:18.097 回答