I have created a content view ,added Boolean property and button to it. When I click the button button I change Boolean property, Notifychanged property triggers but UI is not updating accordingly.
String property updates working fine. Bool, Observable collections not working.
Please find sample code below
xaml:
<Label
Margin="0,-5,0,0"
Padding="10,0"
FontAttributes="Italic"
HorizontalOptions="EndAndExpand"
Text="{Binding IsBusy, Source={x:Reference CustomView}}" />
<Button IsVisible="{Binding IsBusy, Source={x:Reference CustomView}}" Text="New" />
<Button
Command="{Binding ChangeBoolValue, Source={x:Reference CustomView}}"
HorizontalOptions="Center"
Text="Change" />
Xaml.cs
public static readonly BindableProperty IsBusyProperty = BindableProperty.Create(nameof(IsBusy),
typeof(bool), typeof(CustomViewControl),
defaultValue: false, defaultBindingMode: BindingMode.TwoWay,
propertyChanged: IsBusyPropertyChanged);
private static void IsBusyPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (CustomViewControl)bindable;
control.IsBusy = (bool)newValue;
}
public bool IsBusy
{
get
{
return (bool)GetValue(IsBusyProperty);
}
private set
{
SetValue(IsBusyProperty, value);
}
}
protected async Task ChangeBoolValue()
{
IsBusy = true;
}