XLabs MVVM NotifyPropertyChanged Raised but Binding not changed

KarineROBINOTKarineROBINOT USMember
edited April 2016 in Xamarin.Forms

Hi all,

I try to implement the MVVM pattern using XLabs in my cross-platform app.
I have a ListView binded to a list with a one way mode. My list is asynchronously populated so when I set the bindingContext of my view, my list is still empty.
When the list is populated, the NotifyPropertyChanged is raised but my listview is still empty.

I tried to implement :
-INotifyPropertyChanged directly,
-override ObservableObject method and event with the new keyword,
-used Fody NotifyPropertyChanged with custom EventInvokerNames,
-change List type to ObservableCollection,
-encapsulate my listView in a grid with a rowdefinition height=*

Can you help me please ?

Thanks in advance.

My code below :
ViewModel

public class BusinessRequestListViewModel : XLabs.Forms.Mvvm.ViewModel
    {
....
private List<BaseBusinessRequestViewModel> _Requests;
public List<BaseBusinessRequestViewModel> Requests
{
get { return _Requests; }
set {
       _Requests = value;
       this.OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs(nameof(Requests))); // RAISED
       this.NotifyPropertyChanged(nameof(Requests)); // RAISED
    }
}
....
}

My Xaml
<ListView ItemsSource="{Binding Requests, Mode=OneWay}" IsPullToRefreshEnabled="true" RefreshCommand="{Binding ReloadCommand}">

ViewModel Creation
public class MainViewModel : MasterDetailPage
{

        public MainViewModel()
        {
            ...
            Page detail = ViewFactory.CreatePage(typeof(BusinessRequestListViewModel), null, null) as Page;

            ...
            App.NavPage = new NavigationPage(detail);
            this.Detail = App.NavPage;
            Resolver.Resolve<IDependencyContainer>()
                    .Register<INavigationService>(t => new NavigationService(this.Detail.Navigation));
        }

Answers

Sign In or Register to comment.