c# - WPF: Error using a custom control in the ItemTemplate of another custom control -


I have a custom control library where I have many custom controls that I use in my main application. I have a simple custom control that lets the user select the pen thickness value from Cambodia. Now, I'm creating a new custom control on the listboxes, and I want to add pen thickness combobox to the new custom content item's matmplate.

I am getting this error:

"Can not make an example of" LineThink's Combobox "defined in the Assembly Custom Control ... Exception removed from the goal of a greeting 'Custom Control' on the object in the markup file '10_T'; component / themes / customlistbox.xaml '.

Here is the XML and code for LineText ColomboBox:

  Namespace Custom Control (public class line dictation Umbabox: combo box) {publicStyleKeyProperty .override metadata (typef (lineTextunes combo box), new frameworkproportematataata (typef (lineTextunesCombobox))}}}  

and lineTickness combobox. In XML:

  & lt; resource tools xmlns = "http: //schemas.microsof T.com/winfx/2006/xaml/presentation" xmlns: x = "http: // Schemas.microsoft.com/winfx/2006/xaml "xmlns: local =" clr-namespace: custom control "& gt; style targetType =" {x: local tie To: Lainticnessinboboks} "Besdon =" {static resource {x: Type combo box}} "& gt; & Lt; Setter property = "item template" & gt; & Lt; Setter.Value & gt; & Lt; DataTemplate & gt; ... & lt; / DataTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt; / ResourceDictionary & gt;  

Here is the XML and the code for my new customlistbox:

  Namespace Custom Control (public class) CustomListBux: List Box (Public Customlistbox) {DefaultStyleKeyProperty OverrideMetadata (typef (customlisting), new frameworkpropertymatetta (typef (customlistbox)); }}}  

and in CustomListBox.Generic.xaml:

  & lt; Processing Zone xmlns = "http://schemas.microsoft.com/winfx/ 2006/xaml/Presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" xmlns: local = "clr- Namespace: custom control "& gt; & Lt; Style TargetType = "{x: type local: custom listbox}" based on = "{static resources {x: type list box}}" & gt; & Lt; Setter property = "item template" & gt; & Lt; Setter.Value & gt; & Lt; DataTemplate & gt; & Lt; Border & gt; ... & lt; Local: LineicNewscombox / & gt; ... & lt; / Border & gt; & Lt; / DataTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt; / ResourceDictionary & gt;  

And here's my generics:

  & lt; Processing Zone xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/Presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" & gt; & Lt; ResourceDictionary.MergedDictionaries & gt; & Lt; Resource Source Source = "Custom Control, Component / Themes / LineTextness ColomboBox. Generic. XML" /> & Lt; Resource Source Source = "Custom Control, Components / Themes / Customlist Box. Generic .xml" /> & Lt; /ResourceDictionary.MergedDocs> & Lt; / ResourceDictionary & gt;  

I think I have some kind of context problem, but it can not be understood what is wrong. The program compiles and runs without any warnings / errors, but when the customlistbox is created in my main application, I get the error listed above. Without incorporating LineThicknessComboBox, CustomListBox works fine.

Can anyone explain why I got this error?

Thank you!

// I think it should be a stable constructor in both cases because dependency properties metadata override is always constant Should be done in the constructor.

  // No public lineTrains combo box () Stable lineTraining combo box () {DefaultStyleKeyProperty.OverrideMetadata (LineThicknessComboBox), New Framework PropertyMatadata (LineThicknessComboBox)); }  

Should only be called within this type of static constructor, which provides this method as the forType parameter, or similar instant via. Following the examples of owner type, the attempt to change the metadata will not take exception, but as a result the system will have incompatible behavior.

From MSDN


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -