Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append WPF resource strings

I want to append two static strings for a single content or header of a WPF object. Something like this:

<MenuItem 
    Header="{x:Static properties:Resources.SEARCH_FOR_DAYS} + 
            {x:Static properties:Resources.ELLIPSES}" /> 

I've played around with ContentStringFormat and the like but can't get it to accept two resources.

like image 357
JoeB Avatar asked May 16 '12 17:05

JoeB


2 Answers

<MenuItem>
    <MenuItem.Header>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{x:Static properties:Resources.SEARCH_FOR_DAYS}" />
            <TextBlock Text="{x:Static properties:Resources.ELLIPSES}" />
        </StackPanel>
    </MenuItem.Header>
</MenuItem>

Alternatively (closer to what you requested):

<MenuItem>
    <MenuItem.Header>
        <MultiBinding StringFormat="{}{0}{1}">
            <Binding Path="{x:Static properties:Resources.SEARCH_FOR_DAYS}"/>
            <Binding Path="{x:Static properties:Resources.ELLIPSES}"/>
        </MultiBinding>
    </MenuItem.Header>
</MenuItem>    
like image 77
Douglas Avatar answered Oct 04 '22 23:10

Douglas


Off the top of my head, you might be able to do:

<MenuItem>
    <MenuItem.Header>
        <TextBlock>
            <Run Text="{x:Static properties:Resources.SEARCH_FOR_DAYS}" />
            <Run Text="{x:Static properties:Resources.ELLIPSES}" />
        </TextBlock>
    </MenuItem.Header>
</MenuItem>
like image 27
Tim Avatar answered Oct 04 '22 21:10

Tim