c# - MvvmCross binding between ViewModel and View doesn't work for buttons -


i using xamarin develop app android in c# using mvvmcross.

the app compiles , runs fine when using 1 of view models bind seekbar, doesn't view models want bind button. view models have similar structure (pretty identical besides names).

a sample of setup presented below:

my view model looks like:

 public interface isomething     {        int methodsomething(int i);     }     public class changesomethingviewmodel : mvxviewmodel     {         private readonly isomething _somethign;     public changesomethingviewmodel(isomething something)     {         _something = something;     }     public override void start()     {         terminate_something = "hello";         base.start();     } . . .         public string terminate;         public string terminate_something         {             { return terminate; }             set { terminate= "pressed"; raisepropertychanged(() => terminate_something); }         } 

i have file methodsomething(int i)

public class changesomething : isystem     {     public int methodsomething(int i)     {         .         .         .     }      } 

in setup.cs

        protected override imvxapplication createapp()         {             mvx.registersingleton<imvxappstart>(new mvxappstart<changesomethingviewmodel>());             return new app();         } protected override void initializefirstchance()         {             mvx.registersingleton<isomething>(new changesomething());             base.initializefirstchance();         } 

in main.axml file have button

<button android:layout_width="wrap_content" android:layout_height="wrap_content" local:mvxbind="click terminate_something" /> 

when run app terminate_something set , displayed in button, expect. however, if place breakpoint in terminate_something , click on button no call terminate_something made.

i should mention can see in log following every time touch button.

04-17 12:57:14.070 d/gesturedetector( 5928): [surface touch event] msweepdown false, mlrsdcnt : -1 mtouchcnt : 7 mfalsesizecnt:0 

i can't quite understand can problem other view model works great linking slider. when press on slider (seekbar) moves , calls set, corresponding log is

04-17 12:57:45.060 d/progressbar( 5928): setprogress = 43, fromuser = true 04-17 12:57:45.060 d/progressbar( 5928): mprogress = 50mindeterminate = false, mmin = 0, mmax = 70 

thank in advance

it looks problem because not binding icommand. also, might missing somewhere, should specify in terminate_something methodsomething, no?

this should fix it: in view model change terminate_something property

 private mvxcommand terminate;    public system.windows.input.icommand terminate_something    {               {            terminate = terminate ?? new mvxcommand(methodsomething);            return terminate;        }    } 

since mentioned seekbar working didn't like?

set { terminate= "pressed"; raisepropertychanged(() => terminate_something); methodsomething();} 

in case stuart has video pretty on thing in n=5

edit:

obviously, can't set terminate "hello" in start()... depending on trying button can bind text "hello" of button different property.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -