我创建了一个包含一些控制(按钮和复选框)的UserControl。UserControl和Windows之间的相互作用
之后,我在WPF Windows中添加了对该UserControl的引用。
我想要做的是:当我点击UserControl中的一个按钮时,这个按钮触发一个动作并改变Windows中的某些东西(Textbox1.Text =“something”)。
我的问题是我无法从UserControl访问Windows内部的控件。
请帮忙吗?
EDIT
:增加了代码示例
<s:SurfaceWindow x:Class="Project.Temp.MainSurface"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
xmlns:local="clr-namespace:Project"
Title="Project.Temp"
>
<Grid x:Name="Root" ... >
<Grid x:Name="Child" ... >
<local:MyUserControl x:Name="UserControlStart" ... />
</Grid>
...
</Grid>
请更多的解释! –
你能发布创建usercontrol实例的代码吗?主窗口的名称是什么? – Jan
用户控件决不应该依赖于其所有者的类型。 –