2

drop down menuユーザーがをクリックしたときにを表示したいbuttoncomboBoxコンボボックスの代わりにボタンのようなものです。どうすればいいですか?

4

2 に答える 2

2

PopupMenuを使用して解決しました。これが他の人の参照用のコードです。

    public static Rect GetElementRect(FrameworkElement element)
    {
        GeneralTransform buttonTransform = element.TransformToVisual(null);
        Point point = buttonTransform.TransformPoint(new Point());
        return new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
    }

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        var menu = new PopupMenu();
        menu.Commands.Add(new UICommand("Label", (command) =>
        {
            //do work
        }));

        // We don't want to obscure content, so pass in a rectangle representing the sender of the context menu event.
        // We registered command callbacks; no need to handle the menu completion event
        var chosenCommand = await menu.ShowForSelectionAsync(GetElementRect((FrameworkElement)sender));
        if (chosenCommand == null) // The command is null if no command was invoked.
        {

        }
    }
于 2012-11-28T07:41:45.720 に答える
1

ミラノ、

ボタンとポップアップを組み合わせたカスタムコントロールまたはユーザーコントロールを作成する必要があります。ボタンとポップアップを使用して、これをインプレースで実装することもできます。Callistoのメニューコントロールを見て、そこからドロップダウンメニューを実装することをお勧めします 。Callistoコントロール(メニューを含む)

于 2012-11-20T01:54:49.933 に答える