如何从工具栏按钮显示PopUp控件 [英] How to show a PopUp control froé a tool bar button

查看:55
本文介绍了如何从工具栏按钮显示PopUp控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我在设计的应用程序中有以下布局:

I have the following layout in the application that I am designing :

我所看到的是当我点击时显示一种弹出控件一个工具栏按钮,以带来更多选项。弹出控件可以包含任何内容。与菜单和子菜单项非常相似。

What I am looking at is to display a kind of Popup control when I click on a toolbar button in order to bring more option. The popup control could contain any thing. Quite similar to menu and sub menu item.

在UWP应用程序中有一个名为Flyoutmenu的控件,如何在WPF中执行此操作?

In UWP app there is such control called Flyoutmenu, how to do this in WPF ?

任何想法和样品欢迎

问候

推荐答案

你没有解释过这方面的一些事情,比如它应该如何重复使用,它应该放在哪里等等。

You've not explained a few things about this like how re-usable it should be, where it should be positioned etc.

明显的候选人包括:

1)一个弹出窗口。您可以相对于控件或绝对位置。

1) A popup. You can position relative to a control or absolute.

2)上下文菜单。我认为您对定位的控制较少,但是当您点击其他地方时,它们就会消失,这很有用。

2) A context menu. I think you have less control over positioning but they disappear when you click elsewhere which is useful.

3)重新模板/样式子菜单,让你点击的东西重新模板/样式菜单。

3) A re-template/styled sub menu and make the thing you're clicking a re-template/style menu.

4)装饰者。如果你从头开始编写代码但是有一个很好的库,这些都很棘手:

http://www.nbdtech.com/Blog/archive/2010/06/21/wpf-adorners-part-1-ndash-what- are-adorners.aspx

4) An adorner. These are tricky if you write the code from scratch but there's a good library: http://www.nbdtech.com/Blog/archive/2010/06/21/wpf-adorners-part-1-ndash-what-are-adorners.aspx

这将允许您轻松地相对于控件进行定位。弹出窗口的优点是装饰器位于其父窗口的顶层,而不是位于所有位置顶部的单独窗口。如果您打开弹出窗口并且用户拖动浏览器或其他
应用程序,则该窗口顶部会出现弹出窗口。这往往会惹恼用户.5)只是一些控件通常会崩溃,但是当您点击某些内容或其他内容时会显示。把它放在你的xaml中,它的z顺序最高。

That would allow you to position relative to a control easily. The plus over a popup is an adorner goes in the top layer of it's parent window rather than a separate window on top of everything. If you leave a popup open and the user drags a browser or another app over then the chances are the pop up appears on top of that window. Which tends to annoy users.5) Just some control which is usually collapsed but shown when you click something or whatever. Put it last in your xaml and it's z-order will be highest.


这篇关于如何从工具栏按钮显示PopUp控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆