0

I have the following code in my test project:

    <StackPanel>
        <TextBlock Height="50" Text="{Binding First}" />
        <TextBlock Height="50" Text="{Binding Last}" />
        <TextBlock Height="50" >
            <TextBlock.Text>
                <MultiBinding StringFormat="{}{0} + {1}}">
                    <Binding Path="First" />
                    <Binding Path="Last" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
    </StackPanel>

First and Last are string properties:

    public string First { get; set; }
    public string Last { get; set; }

    public MainWindowViewModel()
    {
        First = "First";
        Last = "Last";
    }

The first two TextBlocks with the single binding work as expected, but the one with the Multibinding doesn't. If possible, I want to avoid using a converter What's wrong with my code?

Hackworth
  • 1,069
  • 2
  • 9
  • 23

1 Answers1

1

MultiBinding works from NET .NET 3.5 SP1

And you got the typo, remove last bracket "}" in String-Format

 <TextBlock.Text>
     <MultiBinding StringFormat="{}{0} + {1}">
         <Binding Path="First" />
         <Binding Path="Last" />
     </MultiBinding>
  </TextBlock.Text>

Please let know if solution works for you

Kaspar
  • 405
  • 4
  • 13
  • Thanks, the typo was indeed the problem. When I open a bracket in the XAML editor, it "helpfully" appends a closing bracket automatically, but unlike the C# editor, it doesn't skip over that closing bracket when I immediately write another closing bracket... – Hackworth Jun 28 '18 at 07:09