What does these exception mean & how to avoid them or is there further documentation. I am modifing the a textblock inlines on binding updates (behavior that formats) inside a datagrid.
Getting this exception from datagrid with virtualization, e.g. virtualized stack panel -> VisualCollection has a guard
VisualCollection.cs, from reference source:
private void ConnectChild(int index, Visual value)
{
//
// -- Approved By The Core Team --
//
// Do not allow foreign threads to change the tree.
// (This is a noop if this object is not assigned to a Dispatcher.)
//
// We also need to ensure that the tree is homogenous with respect
// to the dispatchers that the elements belong to.
//
_owner.VerifyAccess();
value.VerifyAccess();
// It is invalid to modify the children collection that we
// might be iterating during a property invalidation tree walk.
if (_owner.IsVisualChildrenIterationInProgress)
{
throw new InvalidOperationException(SR.Get(SRID.CannotModifyVisualChildrenDuringTreeWalk));
}
}
Meaning of the flag:
// Are we in the process of iterating the visual children.
// This flag is set during a descendents walk, for property invalidation.
IsVisualChildrenIterationInProgress = 0x00000010
I mean there must be a concept of how to work to avoid this exception with WPF controls either as paradigm or certain checks & code in certain key code paths that I should be aware of. Or where should I turn to get such information?
I clone my question from microsoft forum
User contributions licensed under CC BY-SA 3.0