Hi all together,
i have serious Problems with Datepicker.
ProjectWorkTimeDetailViewModel.cs
public class ProjectWorkTimeDetailViewModel
{
more code..................
public override void OnNavigatedTo(NavigationParameters parameters)
{
base.OnNavigatedTo(parameters);
if (parameters.ContainsKey("PWT"))
{
var projectWorkTime = (ProjectWorkTime)parameters["PWT"];
CurrentWorkTime = new ProjectWorkTimeEdit(projectWorkTime);
CurrentWorkTime.PropertyChanged += OnPropertyChange;
}
}
private void OnPropertyChange(object sender, PropertyChangedEventArgs e)
{
if (!Title.EndsWith("*"))
{
Title = Title + " *";
}
_canSave = true;
SaveCommand.RaiseCanExecuteChanged();
}
}
ProjectWorkTimeDetail.xaml
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="13,0">
<Label Text="Arbeitstag: " VerticalOptions="Center"></Label>
<DatePicker Format="dd MMM yyyy"
Date="{Binding CurrentWorkTime.WorkDay,Mode=TwoWay}"
HorizontalOptions="FillAndExpand"></DatePicker>
</StackLayout>
</ViewCell>
ProjectWorkTimeEdit.cs
public class ProjectWorkTimeEdit : BindableBase
{
ProjectWorkTime _entity;
public ProjectWorkTimeEdit (ProjectWorkTime entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
_entity = entity;
_workDay = entity.WorkDay;
_job = _entity.Job;
_workTime = _entity.WorkTime;
}
DateTime _workDay;
public DateTime WorkDay
{
get => _workDay;
set => SetProperty(ref _workDay,value);
}
........... more code
}
As you can see i'm initializing 'ProjectWorkTimeEdit.cs' and set values in the Constructor. After that, i add the 'OnPropertyChanged' EventHandler.
Directly after this Line:
CurrentWorkTime.PropertyChanged += OnPropertyChange;
I have a Event fired from
public DateTime WorkDay
{
set => SetProperty(ref _workDay,value);
}
here without doing anything
I'm shure that this problem has something todo with the Datepicker because if i commented out the Datepicker all works as expected.
Any idea???
Thanks in advance
Peter