Xamarin Forms ListView ObservableCollection not updating

I have ListView, related to ObservableCollection, consisting of viewModels.

viewModel looks like this:

public string Id{ get; set; }
public string Name{ get; set; }
public bool HasId
{
    get { return !(String.IsNullOrEmpty(Id)); }
}

in the xaml interface:

<ListView x:Name="MyList" ItemsSource="{Binding MyList}">
  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell>
        <StackLayout>
          <Label Text="{Binding Name" FontSize="Small"/>
          <StackLayout Spacing="20">
            <Entry Text="{Binding Id}"/>
            <Button Text="Create Profile" IsEnabled="False">
              <Button.Triggers>
                <DataTrigger TargetType="Button" Binding="{Binding HasId}" Value="True">
                  <Setter Property="IsEnabled" Value="True"/>
                </DataTrigger>
              </Button.Triggers>
            </Button>
          </StackLayout>
        </StackLayout>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

Desired result : when the user enters a record (attached to Id), the button should be turned on.

Actual result : when a user enters a record, nothing happens (I assume I ObservableCollectiondon't see the change in viewmodel)

Note. When I add / remove an item to / from ObservableCollection, the view is updated (as expected).

Any suggestions and ideas are welcome!

+4
source share
2

INotifyPropertyChanged viewmodel.

ObservableCollection<T> , - //etc. , .

+6

Called OnTextChanged (- , , Xaml .

, listView , ObservableCollection "MyList"? OnPropertyChanged ?

0

All Articles