Я хочу создать очень базовый пользовательский элемент управления, который обновит свою метку, если этикетка изменяется в модели содержащегося представления < /p>
Моя настройка такая же: < /p>
public partial class BindTest : ContentView
{
public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(BindTest), string.Empty, propertyChanged: TitleChanged);
static void TitleChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (BindTest)bindable;
control.Title = newValue as string;
}
public string Title
{
get => (string)GetValue(BindTest.TitleProperty);
set => SetValue(BindTest.TitleProperty, value);
}
public BindTest()
{
InitializeComponent();
}
}
< /code>
< /code>
And i consume my custom control like this and bind my property from my VM (annotated as ObservableProperty)
< /code>
If i press a Button that executes a command my TestString will be overriden and updated correctly. the separate label beneath my custom controls displays the changing value correctly.
did i misinterpret the use case of custom controls or is something wrong the way i setup things?
Подробнее здесь: https://stackoverflow.com/questions/739 ... m-controls