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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:40:49+00:00 2026-06-02T08:40:49+00:00

So I just want to make a simple combo box that has 2 values,

  • 0

So I just want to make a simple combo box that has 2 values, true and false. The catch is the item I want to bind to should receive a “1” for true and a “0” for false. I am trying to accomplish with pure xaml if possible (converter would be acceptable, but I have thus not been able to get it to work). Here’s my code…

            <ComboBox SelectedItem="{Binding Criteria,Converter={StaticResource BoolToIntConverter}}">
                <ComboBox.Items>
                    <ComboBoxItem Name="True" Content="True" />
                    <ComboBoxItem Name="False" Content="False" />
                </ComboBox.Items>
            </ComboBox>

The converter just looks like this…

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        ComboBoxItem cbo = new ComboBoxItem();

        if (value.ToString() == "1")
            cbo.Name = "True";
        else
            cbo.Name = "False";
        return cbo;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value.ToString().Contains("True"))
            return 1;
        return 0;
    }

It works in the sense that if I select True “1” is set correctly and vice versa, however it also needs to set the current item to True / False if the property is changed to 1 or 0 by another place in the code. Inotifyproperty changed is setup correctly on the bound string, I can break point the covert being called, but the item does not change. Is there a simple way to make a value / index relationship with a combo box in purely xaml (I don’t want to have to use a backing object to achieve this). If not is there a way to correct my converter to get the behavior I’m looking for?

  • 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-02T08:40:51+00:00Added an answer on June 2, 2026 at 8:40 am

    It is possible to apply a control template on a checkbox to make it display as a combobox. Example of how this can be done in XAML follows:

    <CheckBox Content="Select" Width="100" Height="22">
            <CheckBox.Style>
                <Style TargetType="{x:Type CheckBox}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <ComboBox>
                                    <ComboBoxItem x:Name="TrueComboBoxItem" Content="True" IsSelected="{Binding IsChecked, RelativeSource={RelativeSource AncestorType=CheckBox}, UpdateSourceTrigger=PropertyChanged}" />
                                    <ComboBoxItem x:Name="FalseComboBoxItem" Content="False" />
    
                                </ComboBox>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>                     
            </CheckBox.Style>
        </CheckBox>
    

    I have verified in Snoop that this works.

    Snoop

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

Sidebar

Related Questions

I want to make a simple 2d terrain with just a few bumps and
I just want to ask is there a simple way in C++ to make
I just want to set a crontab using that I want to make a
Edit For simplicity: I just want to make the most basic possible cursor that
I just want to make a simple native query with EclipseLink, but I can't
Its probarbly a simple 3-tier problem. I just want to make sure we use
Just want to make simple extension for syntactic sygar : public static bool IsNotEmpty(this
I am new to python, and just want to make a simple change. We
ok pretty simple but i dont know how... i just want to make an
I had make a simple app into a facebook page and I just want

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.