I have a binding in XAML which is linked to an list of objects as the ItemsSource. On Android when I update the ItemsSource it updates the binding in the XAML succesfully.
However on iOS this does not work for some reason. Can anyone suggest why ?
Initial declaration of the ItemsSource :
users.ItemsSource = new System.Collections.ObjectModel.ObservableCollection<AccountGroup>(Accounts);
CS Code which updates the ItemsSource :
users.ItemsSource = null;
users.ItemsSource = new System.Collections.ObjectModel.ObservableCollection<AccountGroup>(Accounts);
This is the Account Group object :
public class Account : INotifyPropertyChanged
{
public string student_unique_id { get; set; }
public string student_fullname { get; set; }
public string organisation_id { get; set; }
public string organisation_title { get; set; }
public string student_token { get;set;}
public string reg_branding_url { get;set;}
public string tint_colour { get;set;}
public string font_colour { get;set;}
public string topup_product_id { get;set;}
public bool isVisible { get; set; }
public string student_initial
{
get
{
return student_fullname[0].ToString();
}
}
public string school_image
{
get
{
return $"{Constants.apiBaseUrl}store/images/uploaded/mobile/{reg_branding_url}";
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class AccountGroup : List<Account>, INotifyPropertyChanged
{
public string organisation_title { get; set; }
public string school_image { get; set; }
public string tint_colour { get; set; }
public string font_colour { get; set; }
public AccountGroup(string orgTitle, string orgImage, string orgTint, string orgFont, List<Account> accounts) : base(accounts)
{
organisation_title = orgTitle;
school_image = orgImage;
tint_colour = orgTint;
font_colour = orgFont;
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
And this is the XAML with the IsVisible property :
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Frame IsVisible="{Binding isVisible}" IsEnabled="False" HasShadow="True" BackgroundColor="White" Padding="0">
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<behaviors:Expander x:Name="MainExpander" CollapseAnimationLength="500" IsExpanded="False" IsVisible="True" >
Can anyone suggest how to fix this ? Seems strange it works on Android and not iOS. Thanks !