c# - ResourceDictionary in separate library -
i have defined resourcedictionary in separate library below
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cultures="clr-namespace:my_localization.cultures" xmlns:properties="clr-namespace:my_localization.properties"> <objectdataprovider x:key="resources" objecttype="{x:type cultures:cultureresources}" methodname="getresourceinstance"/> <objectdataprovider x:key="cultureresourcesds" objecttype="{x:type cultures:cultureresources}"/> </resourcedictionary> i have used library library below (header of xaml only)
<msribbon:ribbontab x:class="ribbon.planner.plannerribbon" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:msribbon="clr-namespace:microsoft.windows.controls.ribbon;assembly=ribboncontrolslibrary" mc:ignorable="d" d:designheight="100" d:designwidth="500" header="{binding path=ribbon_about, source={staticresource resources}}" > <grid> ... ... ... </grid> i have added reference of my_localization lib , changing header. works fine problem in design time have "header="{binding path=ribbon_about, source={staticresource resources}}" underlined. when hover mouse there hint "the resource "resources" not resolved"
why there error hint in xaml? , why work fine?
my solution structure
- mainexe - contains app.xaml. have merged resource dictionary here. no problems in xaml since merge dictionary exists in app.xaml
- my_localization - lib containing resource dictionary (code above)
- lib1 - references my_localization , there problems in xaml explained
- lib2 - references my_localization , there problems in xaml explained
- lib3 - references my_localization , there problems in xaml explained
you need provide reference resourcedictionary either in app.xaml file or locally. resources in app.xaml available globally xaml files of application.
for xaml files in library projects designer works little differently.
at runtime app.xaml in startup project used assemblies. @ designtime app.xaml of local assembly. means, can add app.xaml file libraies, used visual studio designer when rendering xaml files specific library (set build action of file page).
to reference resourcedictionary this:
<application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <application.resources> <resourcedictionary> <!-- other global resources --> <resourcedictionary.mergeddictionaries> <resourcedictionary source="pack://application:,,,/assemblyname;component/folderpath/rdname.xaml" /> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> </application> where assemblyname name of assembly resourcedictionary (check properties of project).
example:
project assembly name: "myassembly" , resourcedictionary in folder path "resources/rds/myrd.xaml"
source="pack://application:,,,/myassembly;component/resources/rds/myrd.xaml"
Comments
Post a Comment