Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

Commented Issue: EvaluateParameter and special values [303]

$
0
0
Hi!
I would like a parameter to be bound to a textBox's Text property. In such case, I don't see any way for CM to distinguish if the parameter is already evaluated or not.
E.g.: if the user types special values, such as "$datacontext", the parameter's value is interpreted.

To overcome this problem, the EvaluateParameter method should probably changed to accept an entire Caliburn.Micro.Parameter as input (not only its properties). This would allow implementors of EvaluateParameter to add custom logic, such as to check for other properties (coming from object derived from Caliburn.Micro.Parameter).
Comments: In the ViewModelBinder.BindActions, the special value is 'guessed' depending on the view-model method signature (e.g. if a parameter is called $dataContext, at runtime the actual DataContext is used as a parameter value), and this behavior should not present any problem, since the method should be called in a view-first scenario. I think that the real issue lies in the ActionMessage.InvokeAction: special values are re-evaluated at invocation time, depending on the Parameter.Value. In such a case, if the parameter is databound to a TextBox, it is possible for the user to provide special values. In my opinion, special values substitution should happen when the Parameter is defined (e.g. Using $dataContext should set the Parameter.Value with a binding to the actual DataContext), and invocation should only use the actual Parameter.Value. Unfortunally, to allow such a thing, the actual ActionExecutionContext should be some-how bindable... I fear that a deeper discussion is needed...

Viewing all articles
Browse latest Browse all 1760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>