I have a ListView
that is bound to an ObservableCollection
composed of viewModels
.
the viewModel looks like this:
public string Id{ get; set; }
public string Name{ get; set; }
public bool HasId
{
get { return !(String.IsNullOrEmpty(Id)); }
}
in the frontend xaml:
<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 user types into entry (binded to Id
), the button should be enabled.
Actual Result: when user types into entry, nothing happens (I'm guessing cause the ObservableCollection
does not see the change within the viewmodel
)
Note: When I add/delete an element to/from the ObservableCollection
, the view does update (as expected).
Any suggestions/ideas are greatly appreciated!