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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:45:07+00:00 2026-05-22T02:45:07+00:00

I have a ListView containing several GridViewColumns. Several of the columns are checkboxes. Each

  • 0

I have a ListView containing several GridViewColumns. Several of the columns are checkboxes. Each column header consists of a checkbox as well, with the intention of checking/unchecking all the checkboxes in that column. Each row’s checkboxes are bound to properties in my view model. I’ve seen several postings where the scenario is a single column of checkboxes, but none of those solutions will work for me, as I have 4 columns of checkboxes. I also need to persist the state of the selections from one visit to the next (all, some or none of the checkboxes in a column could be checked).

Here’s an abbreviated version of the XAML for my ListView:

<ListView ItemsSource="{Binding AveragingParameters}">
  <ListView.View>
    <GridView AllowsColumnReorder="False">

      <GridViewColumn Header="Parameter">
        <GridViewColumn.CellTemplate>
          <DataTemplate>
            <DockPanel>
              <TextBlock Text="{Binding Name}" />
            </DockPanel>
          </DataTemplate>
        </GridViewColumn.CellTemplate>
      </GridViewColumn>

      <GridViewColumn>
        <GridViewColumn.CellTemplate>
          <DataTemplate>
            <Grid HorizontalAlignment="Stretch">
              <CheckBox  x:Name="chkAvg" IsChecked="{Binding CalcAverage}" />
            </Grid>
          </DataTemplate>
        </GridViewColumn.CellTemplate>
        <Grid>
          <CheckBox x:Name="chkAvgSelectAll" Content="Avg" ToolTip="Select All" />
        </Grid>
      </GridViewColumn>

      <GridViewColumn>
        <GridViewColumn.CellTemplate>
          <DataTemplate>
            <Grid HorizontalAlignment="Stretch">
              <CheckBox  x:Name="chkMin" IsChecked="{Binding CalMin}" />
            </Grid>
          </DataTemplate>
        </GridViewColumn.CellTemplate>
        <Grid>
          <CheckBox x:Name="chkMinSelectAll" Content="Min" ToolTip="Select All" />
        </Grid>
      </GridViewColumn>

    </GridView>
  </ListView.View>
</ListView>

I’ve tried using Commands and Command Parameters, PropertyChanged events on the Checked property, and handling the Checked event in my code behind, but nothing gives me enough information to know what to change in the collection I’m bound to.

I suppose I could create a separate event handler for each, but I’d like to be able to handle this in a single event handler if possible, because eventually I will be creating a custom control that is a bit more malluable in terms of the columns displayed.

Thanks in advance

  • 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-22T02:45:07+00:00Added an answer on May 22, 2026 at 2:45 am

    I’ve solved my issue using a Command along with a Tag containing the name of the model property I want set and a CommandParameter set to a multi-binding that is bound to the Tag and the Checkbox’s IsSelected property. The code follows:

    My View’s Xaml Resources:

    <UserControl.Resources>
       <converters:NameValueMultiBindingConverter x:Key="SelectAllConverter" />
    </UserControl.Resources>
    

    My View’s Xaml:

    <ListView ItemsSource="{Binding AveragingParameters}">
      <ListView.View>
        <GridView AllowsColumnReorder="False">
    
          <GridViewColumn Header="Parameter">
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <DockPanel>
                  <TextBlock Text="{Binding Name}" />
                </DockPanel>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
    
          <GridViewColumn>
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <Grid HorizontalAlignment="Stretch">
                  <CheckBox  x:Name="chkAvg" IsChecked="{Binding CalcAverage}" />
                </Grid>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
    
            <CheckBox x:Name="chkAvgSelectAll" Content="Avg" 
                      Tag="CalcAvg" Command="SelectAllCheckedCommand" 
                      ToolTip="Select All">
                <MultiBinding Converter="{StaticResource SelectAllConverter}">
                  <Binding Path="Tag" RelativeSource="{RelativeSource self}" />
                  <Binding Path="IsChecked" RelativeSource="{RelativeSource self}" />
                </MultiBinding>
            </CheckBox>
          </GridViewColumn>
    
          <GridViewColumn>
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <Grid HorizontalAlignment="Stretch">
                  <CheckBox  x:Name="chkMin" IsChecked="{Binding CalMin}" />
                </Grid>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
    
            <CheckBox x:Name="chkMinSelectAll" Content="Avg" 
                      Tag="CalcMin" Command="SelectAllCheckedCommand" 
                      ToolTip="Select All">
                <MultiBinding Converter="{StaticResource SelectAllConverter}">
                  <Binding Path="Tag" RelativeSource="{RelativeSource self}" />
                  <Binding Path="IsChecked" RelativeSource="{RelativeSource self}" />
                </MultiBinding>
            </CheckBox>
          </GridViewColumn>
    
        </GridView>
      </ListView.View>
    </ListView>
    

    My MultiValueConverter:

    public class NameValueMultiBindingConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter,
                              System.Globalization.CultureInfo culture)
        {
    
            var parameters = (object[])values;
            return new NameValueConverterResult 
                            { 
                               Name = (string)parameters[0], 
                               Value = parameters[1] 
                            };
        }
    
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, 
                                    System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    The result object I’m using in the converter:

    public class NameValueConverterResult
    {
        //The name of the model property to set
        public string Name { get; set; }
    
        //The value we're setting it to
        public object Value { get; set; }
    }
    

    The DelegateCommand (I’m using PRISM) and handler in my View Model

    public ICommand SelectAllCheckedCommand { get; private set; }
    private void OnSelectAllCheckedCommand(object arg )
    {
       if (arg == null || !(arg is NameValueConverterResult)) return;
    
       NameValueConverterResult prop = arg as NameValueConverterResult;
    
       //Reflect on the model to find the property we want to update.
       PropertyInfo propInfo = Averagers.FirstOrDefault().GetType().GetProperty(prop.Name);
       if (propInfo == null) return;
    
       //Set the property on the Model
       foreach (var item in Averagers)
          propInfo.SetValue(item, prop.Value, null);
    } 
    

    I hope I’m not abusing StackOverflow providing the solution I came up with. I wasn’t sure of the etiquette here.

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

Sidebar

Related Questions

I have a ListView in ASP.NET where one column consists checkBoxes. I want the
I have a ListView containing file names. These file names need to be draggable
I have a listview that is binded to a ThreadSafeObservableCollection. The background of each
I have a ListView where each item is a TextView . I want to
I have a ListView, and I want to customize the layout of each item
I have a ListView control, and I'm trying to figure out the easiest/best way
I have a ListView which sometimes I need to put around 10000 items in.
I have a ListView in WPF that is databound to a basic table that
I have a ListView on a page that displays a list of widgets. When
I have a ListView inside of an Update Panel and wanted to change the

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.