0
を返します
xamarin.formsにユーザーコントロール(ユーザービュー)を作成します。私のcontolには1つのプロパティがあります。コントロールが要素にページに追加する要素を選択します(エントリまたはラベル)。私はBindablePropertyを使用しますが、デフォルト値のみを返します。私は間違ったことを理解していませんか?Bindableプロパティはデフォルト値の
ここに私のユーザーコントロールコード:
public partial class UserView : ContentView
{
public UserView()
{
InitializeComponent();
StackLayout stackLayout = new StackLayout();
if (TypeElement == "label") //TypeElement return only "default value"
stackLayout.Children.Add(new Label { Text = "LABEL" });
else
stackLayout.Children.Add(new Entry { Text = "ENTRY" });
Content = stackLayout;
}
public static readonly BindableProperty TypeProperty = BindableProperty.CreateAttached("TypeElement", typeof(string), typeof(UserView), "default value");
public string TypeElement
{
get
{
return (string)GetValue(TypeProperty);
}
set
{
SetValue(TypeProperty, value);
}
}
}
ここで私はページ上の私のコントロールを使用します。
ありがとうございました。あなたは私を助けてくれました。 –
私の質問について私は "CountTextBox"、 "CountLabel"とe.t.cのようないくつかのプロパティを持つユーザーコントロールを作成しようとします。このプロパティはXAMLを入力してから複雑なコントロールを取得する必要があります。私の目標 - いくつかの "動的な"コントロール。 –