I have a pop up
<DataTemplate>
<Grid
Padding="10"
ColumnDefinitions="*,*"
RowDefinitions="*,*,*,*"
RowSpacing="20">
<Border
Grid.ColumnSpan="2"
Style="{x:StaticResource CommonBorderStyle}">
<Entry
Text="{x:Binding Turbine.Name}"
TextColor="Black" />
</Border>
<Border
Grid.Row="1"
Grid.ColumnSpan="2"
Style="{x:StaticResource CommonBorderStyle}">
<Grid ColumnDefinitions="*,60">
<Entry
IsReadOnly="True"
Text="{x:Binding Turbine.StringifyInstalationDate}"
TextColor="Black" />
<Button
Grid.Column="1"
Command="{Binding OpenDatePickerCommand, Source={x:RelativeSource AncestorType={x:Type vm:TurbinesCollectionPageViewModel}}}"
CommandParameter="{x:Binding Source={x:Reference picker}}"
FontFamily="ma"
FontSize="Large"
Text="{x:Static constant:MaterialFonts.Calendar_month}"
VerticalOptions="Center" />
</Grid>
</Border>
<picker:SfDateTimePicker
x:Name="picker"
Grid.Row="4"
Style="{x:DynamicResource DateTimePickerStyle}">
<picker:SfDateTimePicker.Behaviors>
<mct:EventToCommandBehavior
Command="{Binding BindingContext.CancelDateCommand, Source={x:Reference TurbinesCollection}}"
CommandParameter="{x:Binding Source={x:Reference picker}}"
EventName="CancelButtonClicked" />
<mct:EventToCommandBehavior
Command="{Binding BindingContext.ConfirmDateCommand, Source={x:Reference TurbinesCollection}}"
CommandParameter="{x:Binding Source={x:Reference picker},
Path=SelectedDate}"
EventName="OkButtonClicked" />
</picker:SfDateTimePicker.Behaviors>
</picker:SfDateTimePicker>
<Border
Grid.Row="2"
Grid.ColumnSpan="2"
Style="{x:StaticResource CommonBorderStyle}">
<Entry
Text="{x:Binding Turbine.Address}"
TextColor="Black"
VerticalTextAlignment="Center" />
</Border>
<Button
Grid.Row="3"
Grid.ColumnSpan="2"
Command="{Binding SaveAndCloseCommand, Source={x:RelativeSource AncestorType={x:Type vm:TurbinesCollectionPageViewModel}}}"
CommandParameter="{x:Binding Source={x:Reference TurbinePopUp}}"
CornerRadius="8"
IsEnabled="{x:Binding IsSaveEnable}"
VerticalOptions="End" />
</Grid>
My model
public partial class Turbine : ObservableObject {
[ObservableProperty]
private int id;
[ObservableProperty]
private string? name;
[ObservableProperty]
private string? address;
[ObservableProperty]
private Location? location;
[ObservableProperty]
private DateTime? instalationDateTime;
[ObservableProperty]
private List<string>? images;
[ObservableProperty]
private string? stringifyInstalationDate;
public string? Label => Name;
}
}
My VM
public partial class TurbinesCollectionPageViewModel(TurbinesService turbinesService,
DeviceLanguageService languageService) :
ChargingStationsMapPageViewModel(turbinesService) {
CollectionView? TurbinesCollection;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsSaveEnable))]
private Turbine? turbine = new();
public bool IsSaveEnable =>
!string.IsNullOrEmpty(Turbine?.Name) &&
!string.IsNullOrEmpty(Turbine?.Address);
Because my model is observable, all of my properties should listen every time right?