Forum Xamarin.Forms

About DATAbinding,How to Binding a temporary object's properties to a INT array[] in C#?

ClawRageClawRage Member ✭✭
edited April 2019 in Xamarin.Forms


My Project want to creat Buttons in C#,and Binding their Text to the Target array[] to display it's number
Like this:

int target[100]=0;

    void CreatButton()

        for (int i = 1; i <= N; i++)

            StackLaout_Hello.Children.Add(  TheButton(i)    );

以及 and

Button TheButton(int i)
     Button B
        BindingContext=???  ///???
        text=??? ///???
        B.SetBinding( Label.TextProperty , new Binding ( Source=target[i+1]  ); ///???
    return B;


我發現我若使用 setBinding 的方式來綁定的話,只有在執行 setBinding 這一行程式時才會更新一次目標數值,是不是我的綁訂條件出了點差錯,最好直接是定BindingContext的條件?
I Found a problem that if I use the code setBinding(QQQ,XXX) to Binding,it will be update Button'text only once when Run this Line,is my Binding code wrong somewhere?or should I set the BindingContext and Text properties Button?

Best Answers


  • ClawRageClawRage Member ✭✭
    edited April 2019

    Thanks for your enthusiasm.
    This is first time I heard about observable collection ,
    I will studding about it.

  • ClawRageClawRage Member ✭✭
    edited April 2019

    this is just a wrong reply

  • LandLuLandLu Member, Xamarin Team Xamurai

    @ClawRage Hi, do you have any update?

  • ClawRageClawRage Member ✭✭
    edited April 2019


    Before attempt grasp LiveView,I use this way integrated send Objects to Object-type array with update range by Array.Resize(), to avoid the problem CODE can't specify that object just built in C#.(However,This way is not use Binding),Hope that after hold the ListView these days, I can abandon this primitive tick.

Sign In or Register to comment.