SIlverlight4 中的提示框

发布于 2025-01-05 17:05:45 字数 350 浏览 1 评论 0原文

我在 Silverlight 页面上捕获了组合键事件。现在,在事件处理程序中,我想显示一个提示框,它接受用户输入并将其存储到字符串变量中。 我输入了这段代码:

string input = System.Windows.Browser.HtmlPage.Window.Invoke("prompt", new string[] { "QUICK SEARCH", "ENTER YOUR SEARCH ITEM.." }) as string;

但是当我运行它时,它显示 AccessViolation 错误的运行时错误未处理,并显示:“尝试读取或写入受保护的内存。这通常表明其他内存已损坏。” 有什么解决办法吗??

I have captured a key-combination-press event on my Silverlight Page. Now in the event handler i want to display a prompt box which takes user input and stores into a string variable.
I put in this code :

string input = System.Windows.Browser.HtmlPage.Window.Invoke("prompt", new string[] { "QUICK SEARCH", "ENTER YOUR SEARCH ITEM.." }) as string;

But when i run it, It shows me a run time error of AccessViolation error was unhandled saying:"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
any Solutions ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半葬歌 2025-01-12 17:05:45

经过大量搜索,我发现 Silverlight 应用程序是单线程活动。
通过上述声明,我试图调用另一个线程。
我必须使用调度程序来解决这个问题。
这就是代码的运行方式..

this.Dispatcher.BeginInvoke(() => javaScriptpopup(sender1, e1));

然后在 javaScriptPopup 中,我调用了我的字符串 input = System.Windows.Browser.HtmlPage.Window.Invoke("prompt", new string[] { "QUICK SEARCH", "ENTER YOUR SEARCH ITEM.." }) 作为字符串;陈述。

这里sender1和e1是Object和Keyeventargs类型!

With lot of searching I found out that Silverlight applcation is a Single Thread activity.
And with the above statement I was trying to invoke another thread.
I had to use the Dispatcher to sort this problem out.
this is how the code goes ..

this.Dispatcher.BeginInvoke(() => javaScriptpopup(sender1, e1));

and then in the javaScriptPopup, I called my string input = System.Windows.Browser.HtmlPage.Window.Invoke("prompt", new string[] { "QUICK SEARCH", "ENTER YOUR SEARCH ITEM.." }) as string; statement.

here sender1 and e1 are the Object and Keyeventargs type!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文