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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:26:45+00:00 2026-06-13T18:26:45+00:00

I have a ListView in WPF Application with CheckBox inside. I am filling that

  • 0

I have a ListView in WPF Application with CheckBox inside.

I am filling that ListView by DataTable with ChapterID and ChapterTitles

<ListView x:Name="listViewChapter" IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" SelectionMode="Multiple" Margin="0,2,-1,3" TabIndex="17" Grid.ColumnSpan="2">
                <ListView.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <UniformGrid Columns="3" />
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </ListView.GroupStyle>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Center">
                            <CheckBox Name="chkChapterTitle" VerticalAlignment="Center" Margin="0,0,0,0" Tag="{Binding ChapterID}" Content="{Binding ChapterTittle}" Checked="chkChapterTitle_Checked" Unchecked="chkChapterTitle_Unchecked" IsChecked="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem},Path=IsSelected}" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

Now i want to access inside CheckBoxes checked that…

My Code is…

        private void ToCheckChapters()
    {
        for (int i = 0; i < listViewChapter.Items.Count; i++)
        {

            // Get a all list items from listbox
            ListViewItem ListBoxItemObj = (ListViewItem)listViewChapter.ItemContainerGenerator.ContainerFromItem(listViewChapter.Items[i]);
            //bool check = ListBoxItemObj.HasContent;
            // find a ContentPresenter of that list item.. [Call FindVisualChild Method]
            ContentPresenter ContentPresenterObj = FindVisualChild<ContentPresenter>(ListBoxItemObj);

                // call FindName on the DataTemplate of that ContentPresenter
                DataTemplate DataTemplateObj = ContentPresenterObj.ContentTemplate;
                CheckBox Chk = (CheckBox)DataTemplateObj.FindName("chkChapterTitle", ContentPresenterObj);
                Chk.IsChecked = true;
        }
    }

    private childItem FindVisualChild<childItem>(DependencyObject obj)
    where childItem : DependencyObject
    {
        for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
        {
            DependencyObject child = VisualTreeHelper.GetChild(obj, i);
            if (child != null && child is childItem)
                return (childItem)child;
            else
            {
                childItem childOfChild = FindVisualChild<childItem>(child);
                if (childOfChild != null)
                    return childOfChild;
            }
        }
        return null;
    }

But in this code ContentPresenterObj is always null…

  • 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-13T18:26:47+00:00Added an answer on June 13, 2026 at 6:26 pm

    I got the answer myself..

    I have to call ToCheckChapters() function after ListView loaded…

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

Sidebar

Related Questions

In a WPF application I have a ListView: <ListView Name=ItemSelList ItemsSource={Binding ItemColl} SelectionChanged=ItemSelList_SelectionChanged> <ListView.View>
I have a WPF ListView that contains CheckBox column and other columns of the
I have a WPF application that has a ListView with a GridView in it.
I have a ListView in a WPF Application that use Dynamic Binding . I
In my WPF application, I have a ListView on the main form that displays
I have a ListView in WPF application with a CheckBox . I want to
I have a WPF ListView that I am trying to filter within a BackgroundWorker.
I have a WPF ListView that should be extended with an always visible footer.
I have a WPF App that implements a ListView. I would like to show
I have a ListView and ObservableCollection in my wpf application. I want to bind

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.