私はユーザーコントロールを持っています-「ControlBase」と言います。これには、「DependencyObject」から継承されたクラスObservableCollection<InheritedFromDO>
である「SomeItems」プロパティがあります。
の子クラスのマークアップを作成するときに、「SomeItems」コレクションを開始したいと思います。しかし、コントロールにはかなり通常のDataContextがあり、バインディングは通常の場合に機能しますが、どういうわけか、そのマークアップでバインディングを使用することはできません。InheritedFromDO
ControlBase
次のようになります。
<local:ControlBase
...
>
<local:ControlBase.SomeItems>
<SomeItem
DepPropertyOne={Binding Id} <!-- Does NOT work here -->
/>
<SomeItem
DepPropertyOne={Binding Name} <!-- Does NOT work here -->
/>
<local:ControlBase.SomeItems>
<Grid>
<TextBlock
Text={Binding Id} <!-- Works here -->
/>
</Grid>
</local:ControlBase>
出力は次のようになります。
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Id; DataItem=null; target element is 'SomeItem' (HashCode=26965808); target property is 'DepPropertyOne' (type 'Object')
それを機能させる方法はありますか?