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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:47:22+00:00 2026-05-25T18:47:22+00:00

I have a ListBox containing an ItemTemplate made up of a StackPanel containing a

  • 0

I have a ListBox containing an ItemTemplate made up of a StackPanel containing a CheckBox and a Label. I want to allow only one list item to be checked at a time. I am having trouble understanding how I can get this accomplished. Here is the XAML describing the listbox:

<ListBox Grid.Row="0"
         Grid.Column="0"
         Width="180"
         HorizontalAlignment="Left"
         x:Name="listboxPlayers"
         ItemsSource="{Binding Players}"
         SelectedItem="{Binding SelectedPlayer, Mode=TwoWay}"
         ScrollViewer.VerticalScrollBarVisibility="Visible">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsDefault, Mode=TwoWay}"
                          VerticalAlignment="Center"
                          Checked="CheckBox_Checked"
                          Unchecked="CheckBox_Unchecked"/>
                <Label Content="{Binding Name}"
                       VerticalAlignment="Center" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

A Player is defined as this:

public class Player
{
    public string Name { get; set; }
    public bool IsDefault { get; set; }
}

My list of Players is defined like this:

public ObservableCollection<Player> Players { get; private set; }

My SelectedPlayer is defined like this:

public static readonly DependencyProperty SelectedPlayerProperty =
    DependencyProperty.Register("SelectedPlayer", typeof(Player), typeof(MainWindow),
        new FrameworkPropertyMetadata());

public Player SelectedPlayer
{
    get { return (Player)GetValue(SelectedPlayerProperty); }
    set { SetValue(SelectedPlayerProperty, value); }
}

I haven’t been able to find a post or question that can help me. I’ve played with using a Checked event handler for the CheckBox but I can’t seem to wrap my head around how I can relate the list to the correct Player in the list because the ListBox doesn’t adjust the SelectedPlayer when the CheckBox is checked or unchecked.

Thanks very much.

  • 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-25T18:47:23+00:00Added an answer on May 25, 2026 at 6:47 pm

    If you have something that should behave like a RadioButton, why not use a RadioButton?

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

Sidebar

Related Questions

I have a simple ListBox.ItemTemplate containing a Label and a TextBox bound to a
I have a listbox containing Users. The datasource is an generic list of the
I want to display a listbox containng list items, I have the following template
I have a ListBox with a rather simple ItemTemplate defined - containing a TextBlock
I have (in C#) a list of objects (each one containing a list) and
I have a ListBox containing CheckBoxes. Xaml looks like this: <ListBox x:Name=lbContactTypes> <ListBox.ItemTemplate> <HierarchicalDataTemplate>
I have a user control containing a listbox. I want to bind to the
I have a ListBox containing a group of 'Expander' items, and what I would
I have DataTemplate containing a TextBox . I'm setting this template to a listbox
The Scenario I have a windows forms application containing a MAINFORM with a listbox

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.