引用控件 [英] Referencing a Control

查看:60
本文介绍了引用控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.xaml文件中标识的WebBrowser控件为:

I have a WebBrowser control identified in my .xaml file as:

在.xaml.cs文件中,我很难弄清楚如何重新控制该控件,以便我可以更新URL字符串。  我正在尝试创建一种方法,以便从我在同一项目中已有的另一个工具的OnClick事件中更新它。

In the .xaml.cs file I am having difficulty figuring out how to refence that control so I can update the URL string.  I'm trying to create a method for updating it from the OnClick event of another tool I already have in the same project.

Brian

推荐答案

您已将控件命名为:

You've named your control:

x:Name="WebControl"

顺便说一句。

这不是一个好名字,因为它与webbrowser非常相似,并没有真正告诉任何人阅读你的标记有关控件的意图或用法。

This is not a great name since it's quite similar to webbrowser and doesn't really tell anyone reading your markup anything about the control's intention or usage.

无论如何。

为什么你的方法有静态?

Why do you have Static on that method?

 public static void SetMapLocation

删除静态,你可以再次使用WebControl.WhateverMethod或WebControl.WhateverProperty。

Remove static and you can just WebControl.WhateverMethod or WebControl.WhateverProperty again.


这篇关于引用控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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