wpf - ResourceDictionary in Generic.xaml of CustomControlLibrary produces errors -


i'm making wpf-customcontrollibrary-project customcontrols. 1 of these label nested textblock textwrapping. when set dependencyproperty horizontalcontentalignement p.e. left, want textalignment of textblock set left too. implememented converter class in article here:

convert horizontalalignment textalignment

then wanted use converter-class in generic.xaml. created resourcedictionary called resources.xaml, lies in rootdirectory of library.

<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                     xmlns:local="clr-namespace:wpfdesignercustomcontrollibrary">     <local:horizontaltotextalignmentconverter x:key="h2talignmentconverter"/> </resourcedictionary> 

then added reference dictionary in generic.xaml , binded textalignment-property of textblock.

<resourcedictionary     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="clr-namespace:wpfdesignercustomcontrollibrary">     <resourcedictionary.mergeddictionaries>         <resourcedictionary source="resources.xaml"/>     </resourcedictionary.mergeddictionaries>      <!--style customcontrol customtextbox-->     <style targettype="{x:type local:customtextbox}" basedon="{staticresource {x:type textbox}}">     </style>      <!--style customcontrol customlabel-->     <style targettype="{x:type local:customlabel}" basedon="{staticresource {x:type label}}">         <setter property="template">             <setter.value>                 <controltemplate targettype="{x:type local:customlabel}">                     <border borderbrush="{templatebinding borderbrush}"                             borderthickness="{templatebinding borderthickness}">                         <label horizontalcontentalignment="{templatebinding horizontalcontentalignment}"                                verticalcontentalignment="{templatebinding verticalcontentalignment}">                             <textblock text="{templatebinding text}"                                        textwrapping="wrap"                                        textalignment="{binding relativesource={relativesource mode=findancestor, ancestortype={x:type label}},                                 path=horizontalcontentalignment, converter={staticresource h2talignmentconverter}}"                                        textdecorations="{templatebinding textdecorations}"/>                         </label>                     </border>                 </controltemplate>             </setter.value>         </setter>     </style> </resourcedictionary> 

but when start wpf-application, uses customcontrollibrary error message, while initialization of library exception thrown. seems there problem source-attribute.

what have done wrong?

thanks in advance!

i still recommend use proper uri notation paths not broken easily.

<resourcedictionary.mergeddictionaries>     <resourcedictionary source="pack://application:,,,/wpfdesignercustomcontrollibrary;component/resources.xaml"/> </resourcedictionary.mergeddictionaries> 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -