WPF - ToolTip with multibinding
I dont't know wich VS version you are using but:
<TextBlock Text="{Binding Description, StringFormat="Description : {0}{}"}">
does not even compile for me.
Just remove the " and the empty brackets like that:
<TextBlock Text="{Binding Description, StringFormat=Description : {0}">
You could also write it like this if you want the ":
<TextBlock> <TextBlock.Text> <Binding Path="Description" StringFormat="Description : {0}" /> </TextBlock.Text> <ToolTipService.ToolTip> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="Description : {0}{1}"> <Binding Path="FirstDescription" /> <Binding Path="SecondDescription" /> </MultiBinding> </TextBlock.Text> </TextBlock> </ToolTipService.ToolTip></TextBlock>
I have tried the following code and that worked perfectly:
<TextBlock Margin="20" Foreground="Black" FontSize="20" FontFamily="Century Gothic" Text="{Binding Name1}"> <TextBlock.ToolTip> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="MultiBinded Tooltip : {0}{1}"> <Binding Path="Name1"/> <Binding Path="Name2"/> </MultiBinding> </TextBlock.Text> </TextBlock> </TextBlock.ToolTip> </TextBlock>
Just delete empty brackets. Next code work as expected:
<TextBlock Text="{Binding Description, StringFormat='Description : {0}'}"> <ToolTipService.ToolTip> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="Description : {0}{1}"> <Binding Path="FirstDescription" /> <Binding Path="SecondDescription" /> </MultiBinding> </TextBlock.Text> </TextBlock> </ToolTipService.ToolTip></TextBlock>
If the StringFormat starts with a left brace { the XAML parser require you to escape it using a pair of braces {}. Otherwise the parser gets confused because braces also are used in the syntax of markup extensions.
Details are found in the XAML documentation for {} Escape Sequence / Markup Extension.
Also, you can't use double quotes with inline binding but single quotes is available.