ContextMenu strikes again: data context not properly updated

Since context menu is not part of visual tree, you cannot use things like ElementName in its bindings. However, a context menu, that context menu will inherit DataContext of its parent control, because it is Freezable.

The trouble is, this inheritance works only once. If datacontext of the parent control later changes, ContextMenu will remain with the old copy. This caused me a real bug today. Argh.

Posted in

Leave a Reply

Your email address will not be published. Required fields are marked *