Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable SelectedDate in Calendar after reusing the control #100

Open
denmusic1992 opened this issue May 30, 2019 · 2 comments
Open

Disable SelectedDate in Calendar after reusing the control #100

denmusic1992 opened this issue May 30, 2019 · 2 comments

Comments

@denmusic1992
Copy link

Greetings!
I have a Calendar control, which I use in such a way:

...
<calendar:Calendar BorderColor="Accent" BorderWidth="2" SelectedBackgroundColor="Accent" x:Name="MyCalendar"
                             SelectedTextColor="White" SelectedBorderWidth="0" TitleLeftArrowTextColor="Accent" StartDay="Monday" WeekdaysShow="False"
                             TitleRightArrowTextColor="Accent" EnableTitleMonthYearView="True" DateCommand="{Binding DateChanged}" Margin="5" 
                             SelectedDate="{Binding SelectedDate}"/>
...

And in my ViewModel:

public class DateDefectContentViewModel : BaseViewModel
{
    ...
    private DateTime? _selectedDate;
    public DateTime? SelectedDate
    {
	 get => _selectedDate;
	 set => SetProperty(ref _selectedDate, value);
    }
...

public DateDefectContentViewModel(CreateDefectModel defectModel)
{
	_defectModel = defectModel;
	SelectedDate = null;
	DateChanged = new DateSelectedCommand(this);
}

protected internal void SelectedDateChanged(object date)
{
	if (_defectModel.CreationDate == Convert.ToDateTime(date))
	{
		_defectModel.CreationDate = null;
		SelectedDate = null;
		SetInteractionHasChanged(false);
		return;
	}
	_defectModel.CreationDate = Convert.ToDateTime(date);
	SelectedDate = _defectModel.CreationDate;
	if (IsForConstrs)
	{
		if (AllConstrs)
		{
			SetInteractionHasChanged(true);
			return;
		}
		if (Nconstr.Count > 0)
		{
			if (Nconstr.Any(i => i.IsChecked))
			{
				SetInteractionHasChanged(true);
				return;
			}
			SetInteractionHasChanged(false);
		}

		SetInteractionHasChanged(false);
	}
	else SetInteractionHasChanged(true);
}
}

Everything works fine when I open the Calendar first time, there is no Date that was selected.
But when I open my page next time, the SelectedDate is exactly that the previous was.
How to disable that?
TIA.

@denmusic1992
Copy link
Author

Would it be fixed? Or any suggestions about how to resolve the issue?

@lubiepomaranczki
Copy link

Hi @denmusic1992 👋
As you may have seen @rebeccaXam is no longer with us hence the nuget is not supported by anyone.
Regarding your problem: is the date selected when you get back to the page with calendar? So you have flow like Page with calendar -> opens new page -> New page -> goes back to page with calendar -> Calendar page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants