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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:31:38+00:00 2026-05-26T05:31:38+00:00

In a Silverlight Web app, I have a service and its interface in where

  • 0

In a Silverlight Web app, I have a service and its interface in where I declared an Enum with the days of the week:

[Serializable]
[DataContract]
[Flags]
public enum WeekDaysFlags : int {
[EnumMember]
Monday = 1,
[EnumMember]
Tuesday = 2,
[EnumMember]
Wednesday = 4,
[EnumMember]
Thursday = 8,
etc.

Back in the application, I have a checkbox for each day that I would like to bind; I did make a pretty converter that accepts a parameter:

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int d;
            if (int.TryParse(parameter.ToString(), out d))
            {
                WeekDaysFlags mask = WeekDaysFlags.Monday;
                switch (d)
                {
                    case 0:
                        mask = WeekDaysFlags.Sunday;
                        break;
                    case 1:
                        mask = WeekDaysFlags.Monday;
                        break;
                    case 2:
                        mask = WeekDaysFlags.Tuesday;
                        break;
                    case 3:
                        mask = WeekDaysFlags.Wednesday;
                        break;
                    case 4:
                        mask = WeekDaysFlags.Thursday;
                        break;
                    case 5:
                        mask = WeekDaysFlags.Friday;
                        break;
                    case 6:
                        mask = WeekDaysFlags.Saturday;
                        break;
                }

                WeekDaysFlags day = (WeekDaysFlags)value;
                return (day & mask) == day;
            }

            return false;
        }

Then the IsChecked property of the checkboxes receives something like below, with parameters from 0 to 6 for each day.

IsChecked="{Binding WeeksDays, Mode=TwoWay, Converter={StaticResource DayOfWeekConverter}, ConverterParameter=1}"

Then I run my program, read the database, bind the object aaaaand… nothing! I expect to have monday and wednesday checked since the WeekDays variable contains 5.
When I debug, I do step into the converter with right value and the right parameter, it does return true or false when it is supposed to do so, but in the UI, none of the checkbox is checked. No comprendo…

For the moment, since I need it to work, I assign IsChecked manually from the code behind…

If you have a solution, that would be great! Also I wonder how the binding will work when I will need to “read” the checked checkboxes; i.e. how to get ‘Monday | Wednesday | Thursday’, or 13, or whatever in my binded variable from the checkboxes /me scratch head

Thank you for your help 😉

Sylvain

  • 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-26T05:31:38+00:00Added an answer on May 26, 2026 at 5:31 am

    The whole bitmask-converter setup strikes me as over-engineering. It will be difficult to get right and it is not very flexible.

    Consider unpacking your enum into an array of booleans on your ViewModel. Make it a List of (bool, string) and you can bind it to an ItemsControl with a CheckBox template. No more repeated code and markup.

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

Sidebar

Related Questions

I have a WCF web-service and a Silverlight app displaying data from that service.
I have a Silverlight web app which uses ASP.net Website administration tool for user
I have built a web setup project in VS2008 which installs my ASP.NET/Silverlight app
I'm writing a silverlight app that queries a web service to populate a tree
When writing a Silverlight app hooked up to a WCF Web Service, the only
I have client apps that talk to my silverlight application and its web services.
I have a silverlight app that talks to a WCF service inside of an
I have a silverlight library that is supposed to get make a web service
I have created a Silverlight Business app, and have created a Domain Service within
I have a WCF Data Service in my web app. I added a service

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.