I have a treeview in a wpf form that initially binds correctly but certain combinations of checking and unchecking items in the tree cause the binding to fail to hold.
Here is the property;
const string HAS_ACCESS = "HasAccess";
public bool? HasAccess
{
get
{
return hasAccess;
}
set
{
if (hasAccess == value) return;
if(!AllowUpdate(value)) return;
//Debug.WriteLine("{0} tried to set hasAccess to a value of {1} D = {2}, A = {3}, u = {4}, AllowChange = {5}, I = {6}", myPermission.Name, value, descendantChanged, ancestorChanged, userInstigatedChange, AllowUpdate(value), isInitialising);
ResetChangeBools();
hasAccess = value;
Debug.WriteLine("HasAccess = {0}", HasAccess);
isInitialising = false;
RaisePropertyChanged(HAS_ACCESS);
}
}
This is the xaml;
<CheckBox Grid.Column="0" Grid.Row="1"
IsThreeState="true"
Content="{Binding MyPermission.Name}"
Click="CheckBox_Clicked"
IsChecked="{Binding HasAccess, Mode=OneWay}"/>
I must stress that the correct value for HasAccess is displayed when the treeview is initialised and does update when changed MOST OF THE TIME but if I check a child item in the treeview (that correctly checks its parent), uncheck its parent (which correctly unchecks its children) then recheck the initial child element the parent no longer checks. I included the Debug.writeline to check that the values were being correctly set and although I can see the correct values in the Output window they are not shown in the checkbox. Ahy help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire