Concatenate StaticResources in WPF

前端 未结 1 870
走了就别回头了
走了就别回头了 2021-01-22 23:42

I need to concatenate two strings from string resources into a label. I want something like this

相关标签:
1条回答
  • 2021-01-23 00:03

    when Content is a string, framework creates a TextBlock behind the scenes to display it. So

    <Label Content="Smth"/>
    

    is transformed into

    <Label>
        <TextBlock Text="Smth"/>
    </Label>
    

    you can add TextBlock in xaml and explicitly assign two strings from Resources:

    <Label>
        <TextBlock>
            <Run Text="{StaticResource Menu}"/>
            <Run Text="{StaticResource Name}"/>
        </TextBlock>
    </Label>
    
    0 讨论(0)
提交回复
热议问题