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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:51:15+00:00 2026-06-13T17:51:15+00:00

So I have a TreeView that has heirarchical data templates that have CheckBoxes in

  • 0

So I have a TreeView that has heirarchical data templates that have CheckBoxes in the lowest layer. These CheckBoxes are bound to a “isChecked” boolean value in the ViewModel. What I have been attempting to do is load the various variables indicating to me which checkboxes to check, change the boolean isChecked in the model to true, therefore resulting in the specific CheckBoxes in the TreeView being update visually. Here is my code for reference:

XAML: (of TreeView I am working with)

<DockPanel Name="test1" Margin="10,10,0,10" VerticalAlignment="Stretch" Grid.Row="3" Grid.RowSpan="7" Grid.Column="0">
        <DockPanel.Resources>
            <local:CheckBoxCommand x:Key="cbc"></local:CheckBoxCommand>
            <src:TreeViewFilter x:Key="MyList" />

            <HierarchicalDataTemplate DataType="{x:Type src:TreeViewParent}" ItemsSource="{Binding Path=OrderAttributes}">
                <TextBlock Text="{Binding Path=NameAndCount}" FontSize="24"/>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type src:OrderAttribute}" ItemsSource="{Binding Path=OrderAttributes}">
                <StackPanel Name="test" Orientation="Horizontal" VerticalAlignment="Center">
                    <CheckBox Command="{StaticResource cbc}"
                              CommandParameter="{Binding Path=NameAndParent}" Visibility="{Binding Path=CheckBoxVisible}" IsChecked="{Binding Path=isChecked, Mode=TwoWay}" VerticalAlignment="Center">
                    </CheckBox>
                    <TextBlock Text="{Binding Path=NameAndCount}" FontSize="16"/>
                    </StackPanel>
            </HierarchicalDataTemplate>

        </DockPanel.Resources>
        <TreeView Name="treeView1" BorderThickness="2" ItemsSource="{Binding Source={StaticResource MyList}, UpdateSourceTrigger=PropertyChanged}" TreeViewItem.Selected="filterByBatchStatus"/>
    </DockPanel>

C# code in ViewModel (pertaining to the problem):

public event PropertyChangedEventHandler PropertyChanged2;

protected void FirePropertyChanged2(string CheckBoxChecked)
    {
        if (PropertyChanged2 != null)
        {
            PropertyChanged2(this, new PropertyChangedEventArgs(CheckBoxChecked));
        }
    }

public static bool cbc;

public bool CheckBoxChecked
    {
        get { return (bool)GetValue(CheckBoxCheckedProperty); }
        set { SetValue(CheckBoxCheckedProperty, value); }
    }

public static readonly DependencyProperty CheckBoxCheckedProperty =
        DependencyProperty.Register("CheckBoxChecked", typeof(bool), typeof(OrderAttribute), new UIPropertyMetadata((bool)false));

bool _isChecked;
    public bool isChecked
    {
        get { return _isChecked; }

        set
        {
            if (_isChecked != value)
            {
                _isChecked = value;
                FirePropertyChanged2("CheckBoxChecked");
            }
        }
    }

If I load the values, update the booleans, and then expand the tree (So I can visually see them), the correct checkboxes are checked and everything works fine. The Problem comes into play when I load different checkboxes after initially visually seeing the first loaded checkboxes, change the booleans, then the Checkboxes do not change according, (dont change at all).

The part that stumps me is that if i do multiple loads, change the booleans over and over, WITHOUT expanding the tree and VISUALLY SEEING the boxes, and then expand the tree, the correct boxes are checked. As soon as I can visually expand and see the checkboxes, any post loading does not update the checkboxes, regardless if whether or not I expand or unexpand the tree.

  • 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-13T17:51:17+00:00Added an answer on June 13, 2026 at 5:51 pm

    Wow… you have some serious issues here. First of all, as I said in your previous question, DependencyProperties don’t belong into ViewModels. Second, your CheckBox is located inside a HierarchicalDataTemplate defined for the Type src:OrderAttribute, and therefore all bindings there are going to search for properties of that type. Third, it is not clear to me what string parameter you are invoking the PropertyChanged event with, but it should be the name of a CLR property in your class, to which the UI is bound. I strongly suggest you take a look at This WPF Tutorial to at least understand the basics of MVVM, INotifyPropertyChanged and DataTemplating, before trying to do complex hierarchical presentation layers.

    Edit: Remove the DependencyProperty from the OrderAttribute Class, and use a regular bool property, then when calling PropertyChanged, do so by passing a string parameter containing the name of that property:

    public bool MyBool 
    { 
       get { return _mybool; }
       set {
             _mybool = value;
             NotifyPropertyChanged("MyBool");
           }
    }
    
    public void NotifyPropertyChanged(string propertyName)
    {
       if (PropertyChanged != null)
           PropertyChanged(this, new PropertyChangedEventArgs(propertyName);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeview control in a Windows Forms project that has checkboxes turned
I have a little WPF app, that has a TreeView to display hierarchical data.
So in my project i would like have a nice treeview that has images.
I have a treeview that is bound to a collection and each item in
I have a TreeView that is bound to a XmlDataSource control. I've added some
I have a TreeView that is bound to a collection class that I have
I have a Masterpage that has Treeview. You can select some nodes there. Based
I have an ASP.NET MVC application that has a jQuery Treeview and a jQuery
I have a GUI that has a treeview on left side and a panel
I have a project that I'm working on that has a TreeView Control in

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.