Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - ToolTip with multibinding

I want to make a tooltip with multibinding inside a text block, but whatever I try it doesn't work.

Here is what I've tried so far:

<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>

But when I try it, what I see on the tooltip is : System.Windows.Controls.TextBlock.

when i try it without tooltipservice, and only tooltip, like this :

<TextBlock Text="{Binding Description, StringFormat='Description : {0}{}'}">
    <ToolTip>
        <TextBlock>
            <TextBlock.Text>
                <MultiBinding StringFormat="Description : {0}{1}{}">
                    <Binding Path="FirstDescription" />
                    <Binding Path="SecondDescription" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
    </ToolTip>
</TextBlock>

The screen just get stuck.

like image 614
Golan Kiviti Avatar asked Dec 29 '15 09:12

Golan Kiviti


1 Answers

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>
like image 109
Ouarzy Avatar answered Oct 27 '22 01:10

Ouarzy