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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:59:22+00:00 2026-05-16T23:59:22+00:00

I’ve got a WPF toolkit datagrid with virtualization turned on. Each row has a

  • 0

I’ve got a WPF toolkit datagrid with virtualization turned on. Each row has a check box bound to a bool in the underlying model.

The check boxes (in addition to the data binding) also have Checked and Unchecked handlers (!) to allow checking multiple items at once if you’ve click one with multiple lines selected.

Here’s the xaml:

<Controls:DataGrid ItemsSource="{Binding UnderlyingData}"
                   AutoGenerateColumns="False"
                   HeadersVisibility="Column">

  <Controls:DataGrid.Columns>
    <Controls:DataGridTemplateColumn Header="Use?" SortMemberPath="Use">
      <Controls:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <CheckBox Style="{StaticResource DataGridCheckBoxStyle}" IsChecked="{Binding Spike}"
                    Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" />
        </DataTemplate>
      </Controls:DataGridTemplateColumn.CellTemplate>
    </Controls:DataGridTemplateColumn>              
  </Controls:DataGrid.Columns>
</Controls:DataGrid>

And the Checked/Unchecked handlers:

private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
    if (!processingMultipleRows)
    {
        UpdateAllSelected(e.OriginalSource as ToggleButton);
        e.Handled = true;
    }
}

private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
    if (!processingMultipleRows)
    {
        UpdateAllSelected(e.OriginalSource as ToggleButton);
        e.Handled = true;
    }
}

private void UpdateAllSelected(ToggleButton checkBox)
{
    processingMultipleRows= true;
    var include = checkBox.IsChecked ?? false;
    tickBoxSelector.ApplyToAllSelected<RowViewModel>(checkBox, p => p.Use = include);
    ViewModel.ProcessUseStateChange();
    processingMultipleRows= false;
}

This code works in every way except one. ViewModel.ProcessUseStateChange() is fairly slow and is currently called once whenever you toggle one or more CheckBoxes. Which is fine, but it’s also called once for each new line appearing in view when you scroll the datagrid, since virtualization means new rows have to be created and their Check state must be set.

Is there a cunning way to determine whether Checked is being called in response to a mouse click or an instantiation of a new row due to virtualization?

  • 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-16T23:59:23+00:00Added an answer on May 16, 2026 at 11:59 pm

    The solution I found in the end was to handle the Click event, rather than Checked/Unchecked, this simplified things hugely:

    <Controls:DataGrid ItemsSource="{Binding UnderlyingData}"
                       AutoGenerateColumns="False"
                       HeadersVisibility="Column">
    
      <Controls:DataGrid.Columns>
        <Controls:DataGridTemplateColumn Header="Use?" SortMemberPath="Use">
          <Controls:DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
              <CheckBox Style="{StaticResource DataGridCheckBoxStyle}" IsChecked="{Binding Spike}"
                        Click="CheckBox_Clicked"/>
            </DataTemplate>
          </Controls:DataGridTemplateColumn.CellTemplate>
        </Controls:DataGridTemplateColumn>              
      </Controls:DataGrid.Columns>
    </Controls:DataGrid>
    

    and:

    private void CheckBox_Clicked(object sender, RoutedEventArgs e)
    {
        UpdateAllSelected(e.OriginalSource as ToggleButton);
        e.Handled = true;
    }
    
    private void UpdateAllSelected(ToggleButton checkBox)
    {
        var include = checkBox.IsChecked ?? false;
        tickBoxSelector.ApplyToAllSelected<RowViewModel>(checkBox, p => p.Use = include);
        ViewModel.ProcessUseStateChange();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
i got an object with contents of html markup in it, for example: string

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.