How can I build a string resource from other string resources in WPF? -
here's 'sample code', including i'm trying do. obviously, doesn't work @ moment, there way can make work?
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:system="clr-namespace:system;assembly=mscorlib"     >     <system:string x:key="productname">foo</system:string>     <system:string x:key="windowtitle">{productname} + main window</system:string> </resourcedictionary>      
the way add computed string resourcedictionary in way create markupextension.  markupextension used this:
<resourcedictionary ...>   <sys:string x:key="productname">foo</sys:string>   <local:mystringformatter     x:key="windowtitle"     stringformat="{0} main window"     arg1="{staticresource productname}" /> </resourcedictionary>   this assumes have created markupextension subclass in "local" namespace named mystringformatterextension has properties named "stringformat", "arg1", "arg2", etc, , has providevalue() method obvious.
note aran points out, binding using stringformatter more common way achieve same effect, , better design.  tradeoff not allow result used part of resourcedictionary.
Comments
Post a Comment