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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:11:11+00:00 2026-05-23T03:11:11+00:00

I am using Data Templates to set the values of checkboxes within a combobox

  • 0

I am using Data Templates to set the values of checkboxes within a combobox as such:

<ComboBox Margin="118,117,163,164" ItemsSource="{Binding collection}">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <CheckBox Content="{Binding Name}"/>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>

This works as it should. My problem is, when the user checks the box, I need to be able to get the content value stored within the checkbox. Is this possible?

Thanks.

  • 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-23T03:11:12+00:00Added an answer on May 23, 2026 at 3:11 am

    You need to bind the Checkbox’s IsChecked property to another property on the backing object for each item. i.e. the type which has the Name should expose a boolean property IsSelected.

    Databinding will update the IsSelected property appropriately, which would be easy for you to access in code. e.g. you can loop over the list and filter all the items that have IsSelected = false.

    Code Sample

    XAML

    <StackPanel>
            <ComboBox ItemsSource="{Binding Items}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <CheckBox Content="{Binding Name}" IsChecked="{Binding IsSelected}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <Button Click="EvaluateSelectedItems">Show Selected</Button>
            <TextBlock>Selected Items</TextBlock>
            <ListBox ItemsSource="{Binding SelectedItems}" DisplayMemberPath="Name" Background="AliceBlue"/>
        </StackPanel>
    

    Code-behind

    public MainWindow()
    {
        InitializeComponent();
        this.DataContext = this;
    
        Items = new List<ItemVM>
                    {
                        new ItemVM {IsSelected = false, Name = "Firefox"},
                        new ItemVM {IsSelected = false, Name = "Chrome"},
                        new ItemVM {IsSelected = false, Name = "IE"}
                    };
    }
    
    public IEnumerable<ItemVM> Items { get; set; }
    private IEnumerable<ItemVM> _selectedItems;
    public IEnumerable<ItemVM> SelectedItems
    {
        get { return _selectedItems; }
        set
        {
            _selectedItems = value;
            if (PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs("SelectedItems"));
        }
    }
    
    private void EvaluateSelectedItems(object sender, RoutedEventArgs e)
    {
        SelectedItems = Items.Where(item => item.IsSelected);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set seletected value to a pre-loaded combobox using silverlight with MVVM.
I have a very simple WPF application in which I am using data binding
I'm using System.Data.Linq.DataContext file for accessing a mdf Database I want to use the
I am using temp data as follow in my controllers - very simple, when
I'm using System.Data.OracleClient.OracleCommand to create a table and fill it out with some data.
I'm using the data mapper pattern in a PHP app I'm developing and have
I am programmatically exporting data (using PHP 5.2) into a .csv test file. Example
Generally I connect and retrieve data using the standard way (error checking removed for
Is SSL secure enough for using sensitive data (like password) in query string? Is
I have my winform application gathering data using databinding. Everything looks fine except that

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.