小编Wil*_*ohn的帖子

当我使用propertychanged将字符串绑定到我的XAML时,为什么我没有得到任何文本?C#Xamarin

尝试通过字符串将文本绑定到我的xaml,并使用propertychanged函数根据int的值更改文本.这是我的代码:

XAML:

<Label Text = "{Binding Forename}" />
Run Code Online (Sandbox Code Playgroud)

码:

public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged (string propertyName)
    {
        var changed = PropertyChanged;
        if (changed != null) {

            PropertyChanged (this, new PropertyChangedEventArgs (propertyName));    
        }

    }

    string info;
    int myInt = 0;

    public string Forename {

        get {
            return info;
        }
        set {
            if (myInt == 0) {
                info = value;
                OnPropertyChanged ("TextOne");
            }

            else if (myInt == 1)
            {
                OnPropertyChanged ("TextTwo");

            }
            else 
            {
                OnPropertyChanged ("TextThree");
            }
        }
    } …
Run Code Online (Sandbox Code Playgroud)

c# xamarin xamarin.forms

1
推荐指数
1
解决办法
88
查看次数

标签 统计

c# ×1

xamarin ×1

xamarin.forms ×1