Hello World简单的菜鸟问题VB Button_Click [英] Hello World simple noob question VB Button_Click

查看:99
本文介绍了Hello World简单的菜鸟问题VB Button_Click的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi All

我在Blend3中创建了一个包含2个用户控件的网格,  UserControl1上有一个按钮,UserControl2上有一个标签。

如何将UserControl1上的按钮点击事件处理程序放入以将label.content文本更改为"Hello World"。在UserControl2上?


label.content =" Hello world" 不起作用

。Me.UserControl2.label.content =" Hello world" 不起作用

UserControl2.label.content =" Hello world" 不工作
我很难过,如何访问其他用户控件上的控件?

如果你知道答案,请帮忙

解决方案

当你说"不起作用"时,我认为你的意思是你实际上无法访问其他控件,期间。 你必须在网格窗口中有一个处理程序来处理所有事情。 您可以通过隧道或冒泡事件处理它(您的用户控件必须在单击按钮时引发事件),但我无法弄清楚为什么您只想让按钮和标签变得如此困难 我认为这是一个人为的例子,并不完全是你在实际项目中做的事情。

我相信我已经在这里为其他人发布了一个示例应用程序,展示了如何让用户控制加注通过主机应用程序可以处理的按钮单击事件。 希望这也可以帮到你: http://social.expression.microsoft.com/Forums/en-US/blend/thread/addb6845-09a6-42a9-bbe7-e1595a6b5654/#25dd75b8-cf5d-443f-91e3-cda9dffcb31d

Hi All

I have created a grid with 2 User Controls in Blend3,  UserControl1 has a button on it, UserControl2 has a label on it.

What do I put in the button click event handler on UserControl1 to change the label.content text to "Hello World" on UserControl2 ?


label.content = "Hello world"  doesnt work

Me.UserControl2.label.content = "Hello world"  doesnt work

UserControl2.label.content = "Hello world"  doesnt work

Im stumped, how do i access the controlls on other user controlls ?

Please help if you know the answer

解决方案

When you say "doesn't work", I assume that you mean that you can't actually access the other control, period.  You'd have to have a handler in the grid's window deal with everything.  You could handle it either via tunneled or bubbled events (your usercontrol would have to raise the event when the button is clicked), but I can't figure out why you'd want to make it so difficult for just a button and a label.  I assume that this is a contrived example and not exactly what you are doing in your actual project.

I believe I've posted a sample application here for someone else that shows how you can make a usercontrol raise an event via a button click that the host application can handle.  Hope this helps you out as well: http://social.expression.microsoft.com/Forums/en-US/blend/thread/addb6845-09a6-42a9-bbe7-e1595a6b5654/#25dd75b8-cf5d-443f-91e3-cda9dffcb31d


这篇关于Hello World简单的菜鸟问题VB Button_Click的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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