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 384611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:23:50+00:00 2026-05-12T15:23:50+00:00

As part of learning WPF I just finished working through an MS Lab Exercise

  • 0

As part of learning WPF I just finished working through an MS Lab Exercise called “Using Data Binding in WPF” (http://windowsclient.net/downloads/folders/hands-on-labs/entry3729.aspx).

To illustrate using an IMultiValueConverter, there is a pre-coded implementation of one where the boolean result is used to determine whether the data binding is relevant for the current user. Here is the code for the convert operation:

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
        // var rating = int.Parse(values[0].ToString());
        var rating = (int)(values[0]);
        var date = (DateTime)(values[1]);

        // if the user has a good rating (10+) and has been a member for more than a year, special features are available
        return _hasGoodRating(rating) && _isLongTimeMember(date);
    }

And here is the wiring to use this in the XAML:

<ComboBox.IsEnabled>
    <MultiBinding Converter="{StaticResource specialFeaturesConverter}">
    <Binding Path="CurrentUser.Rating" Source="{x:Static Application.Current}"/>
    <Binding Path="CurrentUser.MemberSince" Source="{x:Static Application.Current}"/>
    </MultiBinding>
</ComboBox.IsEnabled>

The code runs fine, but the XAML designer will not load with a “Specified cast not valid.” error. I tried a couple of ways to not use a cast, one of which I left uncommented in the code above. The funny thing is a finished lab exercise provided by MS also has the error.

Does anyone know how to fix it to make the designer happy?

Cheers,
Berryl

  • 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-05-12T15:23:51+00:00Added an answer on May 12, 2026 at 3:23 pm

    Problem here is that you use Application.Current, which is different in Design mode and in runtime.

    When you open designer, Application.Current will not be your “App” class (or whatever you name it). Thus there are no CurrentUser property there, and your get that error.

    There are multiple ways to fix it. The easiest one is to check if you are in design mode:

    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
      if (Application.Current == null ||
          Application.Current.GetType() != typeof(App))
      {
        // We are in design mode, provide some dummy data
        return false;
      }
    
      var rating = (int)(values[0]);
      var date = (DateTime)(values[1]);
    
      // if the user has a good rating (10+) and has been a member for more than a year, special features are available
      return _hasGoodRating(rating) && _isLongTimeMember(date);
    }
    

    Another approach would be not using Application.Current as a source for your binding.

    Hope this helps :).

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

Sidebar

Ask A Question

Stats

  • Questions 256k
  • Answers 256k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer return (from el in elements from i in el.Ints select… May 13, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer Did you check the section 12.6. JPA of the Chapter… May 13, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer Not sure if this helps your problem but this blog… May 13, 2026 at 10:29 am

Related Questions

Lately, Microsoft keeps coming out with new technologies Linq, WF, WPF, etc... Seems to
I am learning Silverlight and WPF on my own to expand my programming base.
I am trying to compare two byte arrays in memory and produce a data
I am currently a CS student at a 4th year(of total 5). I`m studying

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.