Why does MultiBinding with a converter not work in a tooltip?

For the fairly complex ToolTip WPF part, I'm trying to use MultiBinding to create rich text based on two properties. The problem is that the MultiConverter binding gets DependencyProperty.UnsetValuefor every element in the array values.

The following works using one Binding:

<ToolTipService.ToolTip>
  <StackPanel>
    <TextBlock>
      <TextBlock.Text>
        <Binding Path="Amt" Converter="{StaticResource singleValueConverter}"/>
      </TextBlock.Text>
    </TextBlock>        
  </StackPanel>
</ToolTipService.ToolTip>

And so, using MultiBindingwith StringFormat:

<ToolTipService.ToolTip>
  <StackPanel>
    <TextBlock>
      <TextBlock.Text>
        <MultiBinding StringFormat='{0:C} in {1}'>
          <Binding Path="Amt"/>
          <Binding Path="Currency"/>
        </MultiBinding>
      </TextBlock.Text>
    </TextBlock>        
  </StackPanel>
</ToolTipService.ToolTip>

But a MultiBindingc Converterdoes not matter:

<ToolTipService.ToolTip>
  <StackPanel>
    <TextBlock>
      <TextBlock.Text>
        <MultiBinding Converter="{StaticResource multiValueConverter}">
          <Binding Path="Amt"/>
          <Binding Path="Currency"/>
        </MultiBinding>
      </TextBlock.Text>
    </TextBlock>        
  </StackPanel>
</ToolTipService.ToolTip>

The links in the last example do not get any meaning. This is not the case outside of ToolTip - what happens, so that in this particular case, the failure fails?

+3
source share
2 answers

Try setting the "OneWay" mode to your binding.

, : http://social.msdn.microsoft.com/Forums/en-IE/wpf/thread/15ada9c7-f781-42c5-be43-d07eb1f90ed4

, DependencyProperty.GetValue DependencyProperty.UnsetValue. , Dependency.UnsetValue. , .

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
    if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue) 
        return "";
    [...]
}
+2

:

<ToolTipService.ToolTip>
    <StackPanel>
        <TextBlock>
            <TextBlock.Text>
                <MultiBinding Converter="{StaticResource multiValueConverter}">
                    <MultiBinding.Bindings>
                        <BindingCollection>
                            <Binding Path="Amt"/>
                            <Binding Path="Currency"/>
                        </BindingCollection>
                    </MultiBinding.Bindings>
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>        
    </StackPanel>
</ToolTipService.ToolTip>
0

All Articles