如何解决绑定到CustomControl模板中的ListBox ItemsSource
我有一个带有ControlTemplate的CustomControl,如下所示:
<ControlTemplate x:Key="ListBoxInputControl" TargetType="{x:Type cc:InputControl}">
<Grid
x:Name="ListRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="Labels"/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<Label...
</Label>
<ListBox
x:Name="PART_ListBox"
Grid.Column="1"
ItemsSource=.... // what goes here?
ItemTemplate="{TemplateBinding ListBoxItemTemplate}"
Foreground="{TemplateBinding LblForeground}"
Background="{TemplateBinding LblBackground}"
SelectedItem="{TemplateBinding CbSelectedItem}">
</ListBox>
</Grid>
</ControlTemplate>
我需要通过Dependency属性“ CbItemsSource”将XmlDataProvider链接到ItemsSource。 这是我到目前为止所拥有的:
<ListViewItem>
<ListViewItem.Resources>
<XmlDataProvider x:Key="CrossSection" XPath="CheckList">
<x:XData>
<CheckList xmlns="">
<ListNode Title="Circ"/>
<ListNode Title="Oct"/>
</CheckList>
</x:XData>
</XmlDataProvider>
</ListViewItem.Resources>
<local:InputControl
Template="{StaticResource ListBoxInputControl}"
ListBoxItemTemplate ="{StaticResource ListNodeTemplate}"
CbItemsSource="{Binding Source={StaticResource CrossSection},XPath=//ListNode,Mode=TwoWay}"
LvSelectedIndex=...../>
</ListViewItem>
但这不起作用。 我收到错误消息:
Error No matching constructor found on type 'System.Xml.Serialization.IXmlSerializable'.
You can use the Arguments or FactoryMethod directives to construct this type.
我认为“ CbItemsSource =” {B ...“”行中的源绑定是问题。
我该怎么办?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。