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

  • SEARCH
  • Home
  • 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 8604361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:33:13+00:00 2026-06-12T02:33:13+00:00

Visual Studio 2010 designer says that unhandled exception occurred in MultiValueConverter but I can

  • 0

Visual Studio 2010 designer says that unhandled exception occurred in MultiValueConverter but I can build my program and it works fine (multibinding also works).

enter image description here

XAML (I set window.DataContext in constructor):

            <ComboBox Name="cbbProfile" DisplayMemberPath="Name" Grid.Row="1" Margin="10,5" Grid.ColumnSpan="3" ItemsSource="{Binding ProfilesData.ProfilesItems}" SelectionChanged="cbbProfile_SelectionChanged" >
                <ComboBox.IsEnabled>
                    <MultiBinding Converter="{StaticResource multiEnabledToEnabled}">
                        <Binding Path="ProfilesData.ProfilesItems.Count" Converter="{StaticResource itemsCountToEnabled}" />
                        <Binding Path="State" Converter="{StaticResource stateToControlsEnabled}" />
                    </MultiBinding>
                </ComboBox.IsEnabled>
            </ComboBox>

Converters:

public class MultiEnabledToEnabled : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    { 
        foreach (object val in values)
        {
            if (!(bool) val)     // <-- EXCEPTION (line 176) HERE 
                return false;
        } 

        return true;
    }    

public class ItemsCountToEnabled : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (int)value == 0 ? false : true;
    }

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

public class StateToControlsEnabled : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var val = (ProgramState)value;
        switch (val)
        {
            ...
            default:
                return true;
        }

    }

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

VS Exception text:

System.InvalidCastException
Specified cast is not valid.
at myassemblyname.MultiEnabledToEnabled.Convert(Object[] values, Type targetType, Object parameter, CultureInfo culture) in C:…\Converters.cs:line 176
at System.Windows.Data.MultiBindingExpression.TransferValue()
at System.Windows.Data.MultiBindingExpression.Transfer()
at System.Windows.Data.MultiBindingExpression.UpdateTarget(Boolean includeInnerBindings)
at System.Windows.Data.MultiBindingExpression.AttachToContext(Boolean lastChance)
at System.Windows.Data.MultiBindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Run(Object arg)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

  • 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-12T02:33:15+00:00Added an answer on June 12, 2026 at 2:33 am

    My best guess is that the binding happens before some initialization, and at least one value in the collection of object is DependencyProperty.UnsetValue, making the cast invalid.

    Now, assuming you have a design time viewmodel set up, you could check beforehand if all the values are indeed booleans:

    if(values.All(v => v is bool))
    {
       //Do regular computation
    }
    else
    {
       //Handle edge case
    }
    

    But as soon as any view gets complicated, the designer breaks, and it is painful to get it working again.

    Expression Blend handles this better, if you absolutely want a designer but can’t be bothered to set up a design time environment, go for it.

    Otherwise do it like most people: forget about the designer.

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

Sidebar

Related Questions

I'm using the android designer in visual studio 2010, and I can put things
In the forms designer of Visual Studio 2010, you can auto-generate event handlers (mostly
Visual Studio 2010, I was able to view xaml in designer. Now every xaml
Visual Studio 2010 RC -> Silverlight Application We have a library of images that
I'm using the Visual Studio 2010 Class Diagram designer and it does a nice
Is it possible to embed the Visual Studio 2010 report designer functionality into my
I noticed that after Service Pack 1 was installed to Visual Studio 2010, the
In Visual Studio 2010 I have made a checkbox (IDC_CHECK1) in the resource designer.
I AM getting an error while opening blogengine.net 2.0 in visual studio 2010 designer
I'm trying to edit my TFS 2010 build templates using the Visual Studio 2010

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.