Skip to content

Binding and MultiBinding have different behavior when return value's type not match targetType #10699

@AccMJZ

Description

@AccMJZ

Description

Binding and MultiBinding have different behavior when return value's type not match targetType.

Reproduction Steps

<TextBlock>
  <TextBlock.Text>
    <Binding Converter="{StaticResource TestConverter}"/>
  </TextBlock.Text>
</TextBlock>
internal class TestConverter : IValueConverter
{
  public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  {
    return 0.46164641164;
  }

🆗

<TextBlock>
  <TextBlock.Text>
    <MultiBinding Converter="{StaticResource TestConverter}"/>
  </TextBlock.Text>
</TextBlock>
internal class TestConverter : IMultiValueConverter
{
  public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  {
    return 0.46164641164;
  }

❌System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property. Double:'0.46164641164' MultiBindingExpression:target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

Expected behavior

all 🆗

Actual behavior

Binding 🆗
MultiBinding ❌

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateRequires further investigation by the WPF team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions