Notifypropertychanged for checkbox "Ischecked" is null when the tree view is in collapsed manner

Hiral Hirani 1 Reputation point
2022-09-13T10:11:35.543+00:00

Hi,

I have a TreeView control with checkboxes for parents and children that are checked by default. I added an event handler for Checked and Unchecked events to handle some after-check activity.
240533-treeview.png

I'm using the NotifyPropertyChanged interface's PropertyChanged event to handle the "IsChecked" property of the checkbox.

private bool isChecked;
public bool Ischecked
{
get { return isChecked; }
set { isChecked = value;
NotifyPropertyChanged(nameof(IsChecked));
}
}

private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

When the tree view is in a collapsed manner and the parent checkbox is unchecked the propertychanged for this property is null. While in the expanded state of tree view, it works fine or even when the tree view is expanded manually and then collapsed by the user and after that, if the user checks\unchecks the checkbox, it works fine.

Has anyone experienced this problem?

Looking forward to your responses.

Regards,
Hiral.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,302 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
767 questions
{count} votes