question

HiralHirani-6320 avatar image
0 Votes"
HiralHirani-6320 asked HuiLiu-MSFT commented

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

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.


dotnet-csharpdotnet-wpf-xaml
treeview.png (5.7 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


NotifyPropertyChanged is a function. What do you mean by "the Notifypropertychanged for this property is null"?


0 Votes 0 ·

sorry not NotifyPropertyChanged but PropertyChnaged is showing as null.

0 Votes 0 ·
Viorel-1 avatar image Viorel-1 HiralHirani-6320 ·

Probably PropertyChanged was not initialised yet. When do you add the event handlers to this property?


0 Votes 0 ·
HuiLiu-MSFT avatar image HuiLiu-MSFT HiralHirani-6320 ·

Hi, @HiralHirani-6320 . Has your problem been solved? If not, could you show me the minimal code that reproduces the problem to test the analysis?

0 Votes 0 ·

0 Answers