Oct 28, 2015 at 10:31 PM
Edited Oct 28, 2015 at 10:32 PM
You are right: $datacontext always returns null, because the control it is attached to doesn't implement IHaveDataContext. The control in question is a Button or a ToolStripButton or a ToolStripMenuItem. The
containing these controls implements IHaveDataContext, but the contained controls themselves, they don't implement this interface.
You must keep in mind this project is a migration from WPF where things are a lot different and all elements have a data context natively (there is no IHaveDataContext interface).
The point here is about usefulness of $datacontext parameter. There are several options:
- Keep it as it is.
- Treat the $datacontext parameter as if it refers to the containing view - in that case, maybe it should be rename to $viewdatacontext.
- Return the nearest ancestor with a non null $datacontext.
Solutions 2 and 3 seem pointless since the view is already available using the $view parameter.
Solution 1 is useless and was included just for compatibility. Do you think it's best to remove it altogether?