0

I want to create a custom control which should display a stylish ComboBox inside it. So 1. LeafControl and 2. LeafComboBox.

I have Kept both the ControlTemplate styles in the same Generic.xaml file, which is not correct i guess. Because during initialization of LeafControl depends upon the template creation of LeafComboBox.

So during loading i am getting exception :

Error Msg:

"The invocation of the constructor on type 'ControlsLibrary.LeafComboBox' that matches the specified binding constraints threw an exception."}"

Inner Error Msg :

"{"PropertyMetadata is already registered for type 'LeafControl'."}

Hence, where should i define the Generics.xml Templates so that i can use customcontrol2 in customcontrol1.

Best Regards, Manoranjan

4

1 回答 1

0

在一个文件中为所有Styles 提供默认s是完全合法的。您的问题是您(可能)已将一个(或多个)s 从您的控件复制并粘贴到另一个控件,但未更新该属性。CustomControlgeneric.xamlDependencyPropertyLeafControlOwnerType

LeafControl只需在您的LeafComboBox控件中搜索并将其替换为LeafComboBox。你看,你不能为同一个对象定义两次相同的属性。

于 2013-11-05T12:11:21.403 回答