in Xamarin Forms I created a Page that contains a custom component which I want to feed a value just like this:
<c:CustomComponent Test="{Binding Test}" />
This, however, doesn't work. When I use a raw number instead of the Binding it works. The problem that I figured out was, that my custom component used a ViewModel / BindingContext. So when I remove the line where I assign my ViewModel to the BindingContext the Binding works.
why is that so and how can I use use both, the BindingContext as well as BindableProperty within my custom component? Or do I have to do everything within my code behind?
For reference some code example how I created the BindableProperty
public static readonly BindableProperty TestProperty = BindableProperty.Create(nameof(Test), typeof(int),
typeof(CustomComponent), propertyChanged: (bindable, oldVal, newVal) => {
Debug.WriteLine("TEST " + newVal);
});
public int Test {
get => (int)GetValue(TestProperty);
set => SetValue(TestProperty, value);
}