I’m pretty new to MAUI development, so I do not get this running. I have a list of messages and each message has a status. I want to allow the user to change each data row’s status. I am already using mvvm.
My XAML looks something like this:
<CollectionView VerticalScrollBarVisibility="Default"
HorizontalOptions="Fill"
VerticalOptions="Fill"
ItemsSource="{Binding ListMessages}">
<CollectionView.Header>
<Grid ColumnDefinitions="*,*">
<Label Text="Header"/>
<Label Text="Status"/>
</Grid>
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Message">
<Frame>
<Grid ColumnDefinitions="*,*">
<Label Text="{Binding Header}" Grid.Column="1"/>
<Picker Grid.Column="2"
x:Name="StatusPicker"
ItemDisplayBinding="{Binding ????}"
ItemsSource="{Binding ????}"
SelectedItem="{Binding ?????}"
/>
</Grid>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
And my ViewModel should look something like this:
public partial class ViewModel : BaseViewModel
{
public ViewModel()
{
ListMessageStatus = new ObservableCollection<MessageStatus>();
}
public ObservableCollection<MessageStatus> ListMessageStatus { get; set; }
}
My MessageStatus looks like this:
public class MessageStatus
{
public int Id { get; set; } = -1;
public string? Name { get; set; }
}
What I want to achieve now is to have a Picker which shows MessageStatus.Name and if I select a different value as Message.Status, then I need a method to be called that receives the whole Message and the new Message.Status to send it to my backend and change those data. For some reason I am not able to select anything else inside the Picker as the message defined in the DataTemplate.