WPF databinding issue for itemsControl in usercontrol?

Include your Solution Namespace in the UserControl definition and then include the class as a resource in Resources like this.

Up vote 0 down vote favorite share g+ share fb share tw.

I have two classes and a usercontrol. Class pvalue { public string value; public bool selected; public pvalue(string v, bool s) { value = v; selected = s; } } class param { public string name { get; set; } public string prefix { get; set; } public IList values { get; set; } public param(string _name, string _prefix, IList _values) { name = _name; prefix = _prefix; values = _values; } } ... ... My intention is to create the class in the application, and set it up as the datacontext of the usercontrol. But I'm very new to WPF, this is a bit over my head.

The databinding isn't working - "BindingExpression path error: 'value' property not found on 'object' ''pvalue'". Can I get some help sort out the databinding for the usercontrol? Thanks a lot.

Wpf data-binding usercontrols itemscontrol link|improve this question asked Jan 25 '11 at 23:51Jack Z244 67% accept rate.

Include your Solution Namespace in the UserControl definition and then include the class as a resource in Resources like this Then Modify your code like following ... ... Hope it helps.

There seems to be a few things wrong here: You should be binding to properties (with getters and setters) and not fields, so change your public fields to properties on your pvalue type. If you want the UI to update when those property values change, look into implementing INotifyPropertyChanged on your pvalue and param types I would use PascalCase for your class names and properties Remove the underscores from your parameter names Make your pvalue parameter names more descriptive You are binding the DataContext of the UserControl to what looks like a type name (param), how did you intend the usercontrol from getting an instance of your param type? Normally, you might do this as a dependency property of your usercontrol, then when you consume that control, you can bind the Param dependency property of your usercontrol to a property returning an instance of your param type on your current DataContext (usually a ViewModel if using MVVM).

Thanks, good points. The test case is actually working after I fixed the property declaration of the class pvalue. – Jack Z Jan 26 '11 at 0:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions