windows phone 7 - WP7, WP8 How to set several ResourceDictionaries to use custom FontFamilies -
i want set custom fonts controls, if set font inside one resourcedictionary , use in styles works fine. approach not fine me, because need have font declarations in separate dictionary styles using them.
in app.xaml
have made several resource dictionaries
<application ...> <application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="resources/resourceagencydictionary.xaml"/> <resourcedictionary source="resources/resourcecommondictionary.xaml"/> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> .... </application>
in resourceagencydictionary.xaml
have myfontfamilynormal
declaration
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <fontfamily x:key="myfontfamilynormal">/gbagencycommon;component/fonts/fonts.zip#gotham book</fontfamily> ..... </resourcedictionary>
in resourcecommondictionary.xaml
want use font family (myfontfamilynormal
):
<resourcedictionary ...> <style x:key="mytextblockvaluestyle" basedon="{staticresource phonetextblockbase}" targettype="textblock"> <setter property="fontfamily" value="{staticresource myfontfamilynormal}"/> .... </style> </resourcedictionary>
the project compiles runtime error
system.windows.markup.xamlparseexception occurred _hresult=-2146233087 _message=cannot find resource name/key myfontfamilynormal
does know how can fix that?
sorry guys, searched solution lot in internet , found it. solution simple (i've tried wrong path file , didn't notice right direction)
so in app.xaml
<application ...> <application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="resources/resourcecommondictionary.xaml"/> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> .... </application>
the resourceagencydictionary.xaml
same
in resourcecommondictionary.xaml
<resourcedictionary ...> <resourcedictionary.mergeddictionaries> <resourcedictionary source="resourceagencydictionary.xaml"/> </resourcedictionary.mergeddictionaries> <style x:key="mytextblockvaluestyle" basedon="{staticresource phonetextblockbase}" targettype="textblock"> <setter property="fontfamily" value="{staticresource myfontfamilynormal}"/> .... </style> </resourcedictionary>
note: source="resourceagencydictionary.xaml"
because file in same folder resourcecommondictionary.xaml
Comments
Post a Comment