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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:15:41+00:00 2026-05-20T10:15:41+00:00

I have run into a problem where a couple of combos that are bound

  • 0

I have run into a problem where a couple of combos that are bound to enums in my model are not working properly. To start off let me tell you that I have 2 areas of my app where the enum can be manipulated. For clarity/simplicity, lets just say there are identicle views on the left and right and the results/summary in the center. When I set the value in one of the views it sets the value through the ViewModel to the Model, as designed, but the combo in the view on the opposite side (again just for clarity/simplicity’s sake) doesn’t seem to have updated. It should have selected the appropriate row/item, but doesn’t. Below are snippets of code that I’m currently using:

//Definition of Enum:
public enum eNumericAndDateOperator 
{ GreaterThan, GreaterThanOrEqualTo, Equals, LessThanOrEqualTo, LessThan, Between, Ignore }


//XAML of Combo in View(s):
<ComboBox>
   <ComboBoxItem Content="" IsSelected="{Binding Path=SelectedOperator, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=Ignore}" />
   <ComboBoxItem Content="&lt;" IsSelected="{Binding Path=SelectedOperator, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=LessThan}" />
   <ComboBoxItem Content="&lt;=" IsSelected="{Binding Path=SelectedOperator, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=LessThanOrEqualTo}" />
   <ComboBoxItem Content="=" IsSelected="{Binding Path=SelectedOperator, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=Equals}" />
   <ComboBoxItem Content="&gt;=" IsSelected="{Binding Path=SelectedOperator, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=GreaterThan}" />
   <ComboBoxItem Content="&gt;" IsSelected="{Binding Path=SelectedOperator, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=GreaterThanOrEqualTo}" />
   <ComboBoxItem Content="Between" IsSelected="{Binding Path=SelectedOperator, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=Between}" />
</ComboBox>

   //Enum Converter code
   public class EnumToBoolConverter : IValueConverter
   {
      #region Methods
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
         if (value == null || parameter == null)
            return value;
         return value.ToString() == parameter.ToString();
      }
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
         if (value == null || parameter == null)
            return value;

         return Enum.Parse(targetType, parameter.ToString(), true);
      }
      #endregion Methods
   }

EnumConverter is your basic Enum to Bool converter class (and yes with ConvertBack defined).

Should I be using the Selected Index on the combo instead? I can’t really load the enum as the combo’s ItemSource through an EnumToIEnumerableConverter or something because I want to customize the visable text for each item…

  • 1 1 Answer
  • 1 View
  • 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-20T10:15:42+00:00Added an answer on May 20, 2026 at 10:15 am

    Why don’t you turn your enum into a simple class that has static properties

    public class Operator
    {
         public string Key { get; set; }
         public string Caption { get; set; }
         ...
    
        public static Operator GreaterThan { get { ... } }
        public static Operator LessThan { get { ... } }  
    
        public static IList<Operator> Operators { get { ... } }
    }
    

    In your ViewModel you add an Operators property that references the static Operator.Operators property

    In your view:

    <ComboBox ItemsSource="{Binding Operators}"
          SelectedItem="{Binding Path=SelectedOperator, Mode=TwoWay}" />
    

    Then create a DataTemplate for the Operator class that displays the Caption. The advantage of this approach is that you can easily add new funcationality to your operator class – with an enum you will always be limited

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

Sidebar

Related Questions

I have run into a problem with Eclipse Indigo, attempting to start up my
I have run into a problem w/ my model for databinding in WPF. I
I have run into this problem a few times and I'm not happy with
I've just installed VS2008 and have run into a problem that I'm sure can
i'm working on a restaurant's website and have run into this annoying problem when
I have run into a problem trying to modify a form I myself have
I have run into a problem... I'm trying to use QTKit in an application
I'm developing an app and have run into a problem with asynchronous calls... Here's
I am new to jQuery and have run into a problem. I have a
I am developing an xbap application and have run into a problem with users

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.