C# WPF static resource containing other static resources

448 views Asked by At

I've just started learning WPF but I can't seem to figure out how to combine two or more string static resources in XAML. I have two static resources, UntitledFileName ("Untitled") and ApplicationName ("SomeAppName"). The third resource, DefaultWindowTitle, should be composed of the aforementioned resources, and should contain the value "Untitled - SomeAppName". How should I specify the two static resources when defining DefaultWindowTitle?

<sys:String x:Key="UntitledFileName">Untitled</sys:String>
<sys:String x:Key="ApplicationName">SomeAppName</sys:String>
<sys:String x:Key="DefaultWindowTitle">...</sys:String>
1

There are 1 answers

0
EldHasp On

I was planning to use "DefaultWindowTitle" as the window's title.

Perhaps this implementation will suit you:

<Window.Title>
    <MultiBinding StringFormat="{}{0} - {1}">
        <Binding Source="{StaticResource UntitledFileName}"/>
        <Binding Source="{StaticResource ApplicationName}"/>
    <MultiBinding>
</Window.Title>