Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有 2 个用户控件的 .NET WPF 浏览器应用程序页面。我希望用户控件 2 中的 textbox.text 等于用户控件 1 中的 textbox.text。
我试过userctrl2.textbox1.text = userctrl1.textbox.text了,但它不起作用。
userctrl2.textbox1.text = userctrl1.textbox.text
我习惯了基于 Windows 窗体的应用程序,但是 WPF 的工作方式有点不同。如何将用户控件 2 中的 textbox.text 设置为等于用户控件 1 中的 textbox.text?
为什么不使用 WPF 方式呢?
第一个文本框控件应该使用两种方式绑定到一个属性。
第二个文本框控件应使用单向绑定绑定到属性。
当您在第一个文本框中键入时,它将更新基础属性,这将反过来通知第二个文本框控件该属性已更改。