在类型中找不到属性 [英] Property not found in type
问题描述
<TextBox binding="{Binding FirstName}" canvas.left="93" canvas.top="8" height="23" x:name="_arFirstName" width="120" isreadonly="True" xmlns:x="#unknown" />
上面是一段XAML代码,我在其中添加了绑定"到仅存在于我的域对象中的属性".顺便说一句,它说文本框"为绑定",并显示一条错误消息:在文本框"类型中找不到属性绑定".我缺少什么才能在C#代码中引用域对象属性?
谢谢.
*注意*并非我所有的代码段都已转移财产.第一部分确实表明它是一个TextBox
The above is a piece of XAML code to which I added Binding to a Property which exists only in my domain object. Incidentally where it says Textbox "Binding" and getting an error that says: The property Binding was not found in type ''TextBox''. What am I missing to get this to refer to my domain object property in my C# code?
Thanks.
*Note* Not all of my snippet was transferred property. The first part does indicate that it is a TextBox
推荐答案
在您的Window
的构造函数或Load
事件中,您需要设置数据上下文到您的业务对象.
In yourWindow
''s constructor orLoad
event, you need to set the data-context to your business-object.
this.DataContext = yourBusinessObject;
并且假定yourBusinessObject
中将具有FirstName
属性.
And it''s assumed that yourBusinessObject
will have the FirstName
property in it.
这篇关于在类型中找不到属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!