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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:23:33+00:00 2026-06-15T14:23:33+00:00

I have recently found out about BindingGroups , and it seem rather nice. But

  • 0

I have recently found out about BindingGroups, and it seem rather nice.
But I can’t get it to work in my ListView that is filled with data represented in DataTemplates.

(In advance I just like to say: sorry for all the code, it’s just to give you a better understanding)

So in XAML it looks something like this:

<StackPanel Name="stpData">
    <StackPanel.BindingGroup>
        <BindingGroup />
    </StackPanel.BindingGroup>

    <!-- This works nice! -->
    <TextBox Text="{Binding Path=name}" />
    <CheckBox IsChecked="{Binding Path=enable}" />

    <!-- This doesn't work so nice... -->
    <ListView Name="lvBools" ItemsSource="{Binding Path=myList}">
        <ListView.View>
            <GridView>
                <GridViewColumn>
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <CheckBox IsChecked="{Binding bools}" />
                            </StackPanel>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>
</StackPanel>

And code-behind:

public MainWindow()
{
    InitializeComponent();

    TestData Data = new TestData()
    {
        name = "Test",
        enable = true,
        myList = new List<TestData.myItem> 
        {
            new TestData.myItem(true), 
            new TestData.myItem(true), 
            new TestData.myItem(false) 
        },
    };

    stpData.DataContext = Data;
    stpData.BindingGroup.BeginEdit();
}

private void btnSave_Click(object sender, RoutedEventArgs e)
{
    stpData.BindingGroup.CommitEdit();
    stpData.BindingGroup.BeginEdit();
}

private void btnCancel_Click(object sender, RoutedEventArgs e)
{
    stpData.BindingGroup.CancelEdit();
    stpData.BindingGroup.BeginEdit();
}

public class TestData
{
    public class myItem
    {
        public myItem(bool b)
        {
            this.bools = b;
        }
        public bool bools { get; set; }
    }

    public string name { get; set; }
    public bool enable { get; set; }
    public List<myItem> myList { get; set; }
}

So what happends it that when I change the name, or press the enable CheckBox, those changes won’t be submitted until I press the SaveButton (btnSave_Click) (not included in the XAML )
Or if I press a Cancel button changes is “restored”.
But if I click one of the checkBoxes in the ListView, those changes will be submitted immediately.

My own guess: The ListView (or maybe even the StackPanel in the DataTemplate) stops the BindingGroup inheritance chain. But in that case, how can I include them?

EDIT
I have also tried to add a new BindingGroup to the DataTemplate:

<DataTemplate>
    <StackPanel x:Name="SPpan">
        <StackPanel.BindingGroup>
            <BindingGroup Name="BGStackPanel" />
        </StackPanel.BindingGroup>
        <CheckBox IsChecked="{Binding Path=bools}" />
    </StackPanel>
</DataTemplate>

Now when I edit the bools (Click them in my ListView ), the source doesn’t get updated, and that’s good, but now I can find no way to save (Commit) the data.
I can’t access neither SPpan nor BGStackPanel from code-behind.
However I have tried the following:

var tmp = (lvBools.View as GridView).Columns[0];
(tmp.CellTemplate.LoadContent() as StackPanel).BindingGroup.BeginEdit();

but also this without success…

EDIT
Ok, so edit II… So I guess that the reason to why the source doesn’t update is because I’m running the Begin/CommitEdit on the Template and not on the actual objects created from the template. So does anyone know how to reach those objects?

  • 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-15T14:23:34+00:00Added an answer on June 15, 2026 at 2:23 pm

    Ok, so thanks to Mr E.L Dunn I mannage to solve this one!

    So in my first EDIT I suggested that I could maybe add a BindingGroup to the StackPanel in the DataTemplate, and that was kind of in the right direction…

    All that’s needed to be done is to add a BindingGroupName to the DataTemplate’s CheckBox.

    <StackPanel Name="stpData">
        <StackPanel.BindingGroup>
            <BindingGroup Name="bindingGroup"/>
        </StackPanel.BindingGroup>
    
        <!-- This works nice! -->
        <TextBox Text="{Binding Path=name}" />
        <CheckBox IsChecked="{Binding Path=enable}" />
    
        <!-- Now this work nice as well! -->
        <ListView Name="lvBools" ItemsSource="{Binding Path=myList}">
            <ListView.View>
                <GridView>
                    <GridViewColumn>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <CheckBox IsChecked="{Binding bools, BindingGroupName=bindingGroup}" />
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </StackPanel>
    

    Simple as that!

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

Sidebar

Related Questions

Recently I have been learning about WMI and WQL. I found out the list
I have recently found out that there exists a method called nth_element in the
I have recently found out that no argument constructor and multiple argument constructor cannnot
I am a windows dev, but I have recently found that I need to
I have recently found out that the future of Qt has become uncertain as
I have recently found myself becoming more negative about EF and cannot help wondering
I have a project that uses JQuery-UI. I recently found formee, which is a
We've recently upgraded one of our SSRS2005 servers to SSRS2008 and have found that
I recently found out about the awesomeness of the iTunes COM for Windows SDK.
I only recently found out about URL rewriting , so I've still got a

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.