Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:19:14+00:00 2026-06-18T02:19:14+00:00

Both cases were solved, look into 1st answer comments for info. This piece of

  • 0

Both cases were solved, look into 1st answer comments for info.

This piece of code compiles though gives an error at runtime. Exception says:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll.

Parse exception happens when I’m trying to set source for the second binding in MultiBinding. I’ve tried hell of a lot of ways and digged through ~20 articles, though I can’t find out what`s wrong in here.

My best guess is that it`s somehow connected to the wrong return type of a converter.

And, btw, when you change TextBox to TextBlock, 1st case works. The second case doesn`t work still.

CASE1

XAML:

<UserControl x:Class="Draft.MainControl"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:draft="clr-namespace:Draft" 
        xmlns:s="clr-namespace:System;assembly=mscorlib" 
        Height="350" Width="352">

    <UserControl.Resources>

        <s:String x:Key="str1">HELLO</s:String>
        <s:String x:Key="str2">WORLD</s:String>

        <draft:StringConverter x:Key="myStringConverter"/>

     </UserControl.Resources>

    <Grid>

        <TextBox Name="tb1">
            <TextBox.Text>
                <MultiBinding Converter="{StaticResource myStringConverter}">
                    <Binding Source="{StaticResource str1}" />
                    <Binding Source="{StaticResource str2}" />
                </MultiBinding>
            </TextBox.Text>
        </TextBox>


    </Grid>
</UserControl>

Code Behind:

public class StringConverter : IMultiValueConverter
{
    public object Convert( object[] values, Type targetType, object parameter, CultureInfo culture )
    {
        return ( values[0].ToString() + values[1].ToString() );
    }

    public object[] ConvertBack( object values, Type[] targetType, object parameter, CultureInfo culture )
    {
        throw new NotImplementedException();
    }
}

Thanks in advance!

CASE2

And another case for the same problem:

        <Grid>
            <TextBlock TextWrapping="WrapWithOverflow">

                <TextBlock.Resources>
                    <s:Int32 x:Key="defaultHeight">2</s:Int32>
                    <s:Int32 x:Key="defaultNum">10</s:Int32>
                    <draft:MultiplierConverter x:Key="myConverter"/>
                </TextBlock.Resources>

                <TextBlock.Text>
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#10;
                </TextBlock.Text>

                <TextBlock.Height>
                    <MultiBinding Converter="{StaticResource myConverter}">
                        <Binding Source="{StaticResource defaultNum}" Mode="OneWay" />
                        <Binding Source="{StaticResource defaultHeight}" Mode="OneWay" />
                    </MultiBinding>
                </TextBlock.Height>
            </TextBlock>
        </Grid>
    </UserControl>
Code behind:
  public class MultiplierConverter : IMultiValueConverter
  {
      public object Convert( object[] values, Type targetType, object parameter, CultureInfo culture )
      {
          if ( values.Count() == 2 && values[0] != DependencyProperty.UnsetValue && values[1] != DependencyProperty.UnsetValue )
          {
              var num = (Int32)values[0];
              var height = (Int32)values[1];

              return ( num * height );
          }

          return 0;
      }

      public object[] ConvertBack( object values, Type[] targetType, object parameter, CultureInfo culture )
      {
          throw new NotImplementedException();
      }
  }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:19:15+00:00Added an answer on June 18, 2026 at 2:19 am

    You have to set Mode="OneWay" on the inner bindings:

    <MultiBinding Converter="{StaticResource myStringConverter}">
        <Binding Source="{StaticResource str1}" Mode="OneWay" />
        <Binding Source="{StaticResource str2}" Mode="OneWay" />
    </MultiBinding>
    

    If you had investigated the XamlParseException in your debugger, you would have realized that there was an InnerException with this message:

    Two-way binding requires Path or XPath.


    Now for your second problem: When you look at the Output Window in Visual Studio, you might observe the following message:

    System.Windows.Data Error: 5 : Value produced by BindingExpression is
    not valid for target property.; Value=’20’
    MultiBindingExpression:target element is ‘TextBlock’ (Name=”); target
    property is ‘Height’ (type ‘Double’)

    I guess that says it all.

    You should perhaps pay attention to the targetType parameter passed to the Convert method. In your case it is System.Double.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried using both ReadProcessMemory() and WriteProcessMemory() in my application,but in both cases I
What is the difference between System.Web.Cache and HTTPContext.Curent.Cache? In which cases both are used?
Both Ruby and Python have the ability of calling the debugger from code (
This is what I've got in a project including fairly complex cases of reflection:
I have the following code in my iPhone application, warning memory leak! This is
Ok, I ran into this tree question which LOOKED simple, but started driving me
Two general questions I'm wondering about both in the case for a given file(.js,
It seems both can be overloaded, but somebody said not..... What's the case?
Html text box should have same font size for both upper and lower case
Both the events are getting fired at the time onblur event. <%@ Page Language=C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.