I'd like to create a popup dialog box in silverlight in which i can manipulate controls, enter data, and return a value. I want it to be modal, so that when it is open, the page "Below" is inaccessible. I havent found an easy way to do this yet. Any suggestions?
我想在silverlight中创建一个弹出对话框,我可以在其中操作控件,输入数据和返回值。我希望它是模态的,所以当它打开时,页面“下面”是不可访问的。我还没有找到一个简单的方法来做到这一点。有什么建议么?
6 个解决方案
#1
12
I know the question asked for a Silverlight 2 solution but in Silverlight 3 (Beta now, RTW in July 2009) there is a built-in ChildWindow that can do everything you're looking for.
我知道要求Silverlight 2解决方案的问题,但在Silverlight 3(现在的Beta版,2009年7月的RTW)中,有一个内置的ChildWindow可以完成您正在寻找的所有内容。
#2
5
I haven't found a perfect solution either. The closest I have seen is this: Using Popup to create a Dialog class
我也没有找到完美的解决方案。我见过的最接近的是:使用Popup创建一个Dialog类
If it is ok to be non-modal, you can try this tip using HtmlPage.PopupWindow(). How to Popup a Browser Window
如果可以是非模态的,可以使用HtmlPage.PopupWindow()尝试这个技巧。如何弹出浏览器窗口
#3
1
I'm new to the Sliverlight framework and am just starting to figure it out, but I have a similar need for a popup modal dialog box. I just tried an idea that looks promising:
我是Sliverlight框架的新手,我刚开始想出来,但我对弹出模式对话框有类似的需求。我刚刚尝试了一个看起来很有希望的想法
- I created a Rectangle (named "Shield") that covers my entire application area. It exists on top of everything in the main app. I set the fill-brush to White, and the opacity-brush to 81% so that the main app contents show through, but lightly (as in disabled). Then make sure the "Shield" is hit-testable. Now, when the "Shield" is visible, it will also, in effect, block all input to the controls below (at least from the mouse, haven't tried keyboard yet). When the app initializes, set the "Shield" visibility to Collapsed. In that state it won't block input to the main app.
- The dialog box is then constructed on another canvas element that exists in the z-order on top of the shield. Normally the dialog box will be invisible, but when I need it, I just set the "Shield" to visible, and the dialog to visible. Since the dialog is on top of the "Shield" I get a very modal-like behavior. When the dialog box is closed, make both the dialog canvas and "Shield" canvas invisible again and the main app is again active.
我创建了一个覆盖整个应用程序区域的Rectangle(名为“Shield”)。它存在于主应用程序中的所有内容之上。我将填充画笔设置为白色,将不透明度画笔设置为81%,以便主要应用程序内容显示,但轻轻地显示(如禁用)。然后确保“盾牌”是可以测试的。现在,当“Shield”可见时,它实际上也会阻止对下面控件的所有输入(至少从鼠标开始,还没有尝试过键盘)。当应用初始化时,将“屏蔽”可见性设置为折叠。在该状态下,它不会阻止对主应用程序的输入。
然后在另一个画布元素上构建对话框,该元素存在于屏蔽顶部的z顺序中。通常对话框是不可见的,但是当我需要它时,我只需将“Shield”设置为可见,并将对话框设置为可见。由于对话框位于“Shield”之上,因此我得到了一种类似模态的行为。关闭对话框后,再次使对话框画布和“Shield”画布不可见,主应用程序再次处于活动状态。
I'm sure this the most brute-force way of doing it and that I will eventually zero in on a more elegant construct, but it works for now.
我敢肯定这是最蛮力的方式,我最终会归结为一个更优雅的结构,但它现在有用。
#4
1
A more elegant solution is here: http://community.devexpress.com/blogs/theonewith/archive/2008/08/06/custom-silverlight-controls-creating-a-reusable-messagebox-dialog-part-i.aspx
这里有一个更优雅的解决方案:http://community.devexpress.com/blogs/theonewith/archive/2008/08/06/custom-silverlight-controls-creating-a-reusable-messagebox-dialog-part-i.aspx
#5
0
I had the same requirement and ScottGu's Building a Basic Modal Dialog Using a User Control was the best solution that fit my requirement.
我有相同的要求,ScottGu使用用户控件构建基本模态对话框是符合我要求的最佳解决方案。
#6
0
Here's a free library that provides one: http://www.vectorlight.net/demos/popup_dialogs.aspx
这是一个免费的图书馆,提供一个:http://www.vectorlight.net/demos/popup_dialogs.aspx
#1
12
I know the question asked for a Silverlight 2 solution but in Silverlight 3 (Beta now, RTW in July 2009) there is a built-in ChildWindow that can do everything you're looking for.
我知道要求Silverlight 2解决方案的问题,但在Silverlight 3(现在的Beta版,2009年7月的RTW)中,有一个内置的ChildWindow可以完成您正在寻找的所有内容。
#2
5
I haven't found a perfect solution either. The closest I have seen is this: Using Popup to create a Dialog class
我也没有找到完美的解决方案。我见过的最接近的是:使用Popup创建一个Dialog类
If it is ok to be non-modal, you can try this tip using HtmlPage.PopupWindow(). How to Popup a Browser Window
如果可以是非模态的,可以使用HtmlPage.PopupWindow()尝试这个技巧。如何弹出浏览器窗口
#3
1
I'm new to the Sliverlight framework and am just starting to figure it out, but I have a similar need for a popup modal dialog box. I just tried an idea that looks promising:
我是Sliverlight框架的新手,我刚开始想出来,但我对弹出模式对话框有类似的需求。我刚刚尝试了一个看起来很有希望的想法
- I created a Rectangle (named "Shield") that covers my entire application area. It exists on top of everything in the main app. I set the fill-brush to White, and the opacity-brush to 81% so that the main app contents show through, but lightly (as in disabled). Then make sure the "Shield" is hit-testable. Now, when the "Shield" is visible, it will also, in effect, block all input to the controls below (at least from the mouse, haven't tried keyboard yet). When the app initializes, set the "Shield" visibility to Collapsed. In that state it won't block input to the main app.
- The dialog box is then constructed on another canvas element that exists in the z-order on top of the shield. Normally the dialog box will be invisible, but when I need it, I just set the "Shield" to visible, and the dialog to visible. Since the dialog is on top of the "Shield" I get a very modal-like behavior. When the dialog box is closed, make both the dialog canvas and "Shield" canvas invisible again and the main app is again active.
我创建了一个覆盖整个应用程序区域的Rectangle(名为“Shield”)。它存在于主应用程序中的所有内容之上。我将填充画笔设置为白色,将不透明度画笔设置为81%,以便主要应用程序内容显示,但轻轻地显示(如禁用)。然后确保“盾牌”是可以测试的。现在,当“Shield”可见时,它实际上也会阻止对下面控件的所有输入(至少从鼠标开始,还没有尝试过键盘)。当应用初始化时,将“屏蔽”可见性设置为折叠。在该状态下,它不会阻止对主应用程序的输入。
然后在另一个画布元素上构建对话框,该元素存在于屏蔽顶部的z顺序中。通常对话框是不可见的,但是当我需要它时,我只需将“Shield”设置为可见,并将对话框设置为可见。由于对话框位于“Shield”之上,因此我得到了一种类似模态的行为。关闭对话框后,再次使对话框画布和“Shield”画布不可见,主应用程序再次处于活动状态。
I'm sure this the most brute-force way of doing it and that I will eventually zero in on a more elegant construct, but it works for now.
我敢肯定这是最蛮力的方式,我最终会归结为一个更优雅的结构,但它现在有用。
#4
1
A more elegant solution is here: http://community.devexpress.com/blogs/theonewith/archive/2008/08/06/custom-silverlight-controls-creating-a-reusable-messagebox-dialog-part-i.aspx
这里有一个更优雅的解决方案:http://community.devexpress.com/blogs/theonewith/archive/2008/08/06/custom-silverlight-controls-creating-a-reusable-messagebox-dialog-part-i.aspx
#5
0
I had the same requirement and ScottGu's Building a Basic Modal Dialog Using a User Control was the best solution that fit my requirement.
我有相同的要求,ScottGu使用用户控件构建基本模态对话框是符合我要求的最佳解决方案。
#6
0
Here's a free library that provides one: http://www.vectorlight.net/demos/popup_dialogs.aspx
这是一个免费的图书馆,提供一个:http://www.vectorlight.net/demos/popup_dialogs.aspx