c# - Exception while setting DataContext -
i have created custom usercontrol exposes dependencyproperties headertitle , headertitleforeground
public partial class pageheadercontrol : usercontrol { public string headertitle { { return (string)getvalue(headertitleproperty); } set { setvalue(headertitleproperty, value); } } public static readonly dependencyproperty headertitleproperty = dependencyproperty.register("headertitle", typeof(string), typeof(pageheadercontrol), new propertymetadata("")); public string headertitleforeground { { return (string)getvalue(headertitleforegroundproperty); } set { setvalue(headertitleforegroundproperty, value); } } public static readonly dependencyproperty headertitleforegroundproperty = dependencyproperty.register("headertitleforeground", typeof(string), typeof(pageheadercontrol), new propertymetadata("")); public pageheadercontrol() { initializecomponent(); (this.content frameworkelement).datacontext = this; } }
but while debugging app throws exception show below:
system.exception occurred _hresult=-2146233088 _message=error hresult e_fail has been returned call com component. hresult=-2146233088 message=error hresult e_fail has been returned call com component. source=system.windows stacktrace: @ ms.internal.xcpimports.checkhresult(uint32 hr) innerexception:
however custom control correctly drawn. so, how can resolve this? critical issue?
your class pageheadercontrol
dependency props registered elevationpageheadercontrol
owner..?
Comments
Post a Comment