-
Notifications
You must be signed in to change notification settings - Fork 4
Debugging guide
Oh noes, it doesn't work!!!
Ok, stop whining. Here's how to quickly debug the viewbindings:
-
Check that the binding string in the widget is correct: you start a binding declaration with
{
and close it with}
. If you want to put more of them, put;
between them. Don't forget to enclose them in"
. Check that the bound widget property is correct (e.g.Text
,Color
etc.). Check that the binding command is correctly written (-
for one-time binding,=
for continuous binding;@
on one or both sides; when in doubt, just put=
and it should work). -
Check that the binding type is correct - don't use one-time setting methods
-
if you don't have a value ready at ViewModel creation time. If the widget or bound data don't get updated, and you expected them to, make sure they use=
for the continuous binding. Also, -
Check that the declared bound property/method corresponds to the property name or properly-prefixed method name (
is
,get
,set
for values,can
&do
couple for commands + declared name). -
Check that the value is either set by the time the binder makes a pass (it's initialized when instantiating a ViewModel) or you have to call
raisePropertyChanged
when set later. -
Check that you're actually inflating the view manually with the custom ViewBinder and ViewModel - and that you're setting the resulting view as the base view using
setContentView()
. -
If using multithreading, check that you called the
raisePropertyChanged
from the UI thread.