wpf - DataBinding fails for a collection property of custom control -
I have user controls - say "controlbase" is the "certain items" property, which is a observation InheritedFromDO is a class inherited from "dependency object".
When I create a markup for a child, I want to start the "SomeItems" collection in the class of ControlBase , but in some way I can not use bindings in that markup, though in normal cases control Is a very common datacontax and compulsive work.
It looks like:
& lt; Local: controlbage ... & gt; & Lt; Local: ControlBase.SomeItems & gt; & Lt; SomeItem DepPropertyOne = {Binding ID} & lt ;! - Does not work here - & gt; / & Gt; & Lt; SomeItem DepPropertyOne = {Binding Name} & lt ;! - Does not work here - & gt; / & Gt; & Lt; Local: ControlBase.SomeItems & gt; & Lt; Grid & gt; & Lt; TextBlock Text = {Binding ID} & lt ;! - Works here - & gt; / & Gt; & Lt; / Grid & gt; & Lt; / Local: ControlBase & gt; Output says:
System.Windows.Data error: 2: Can not control frameworkElement or FrameworkContentElement for target element. BindingExpression: Path = Id; DataItem = Null; Target element 'Some elements' (hashcode = 26965808); The target property is 'DepPropertyOne' (type 'object')
How does this work out any ideas?
That's because the items in the collection are not part of the logical tree if you want to work , Or sub-squares (e.g.,.) With such control for you.
Comments
Post a Comment