Right now i have a calendar
which is : https://github.com/lubiepomaranczki/XamForms.Controls.Calendar, if i click on the day and there's data for this day, it lists the data for this day like that :
[
My problem is that i don't know how to go from ViewModel to code behind to tell him to switch the IsVisible value to true. I never faced this problem, usually we just send data from the UI to ViewModel.
Thanks for help.
If i click a date with no value
, i want to make this stacklayout which is from CalendarPage.xaml visible
:
<StackLayout IsVisible="false" x:Name="PlusIconStackLayout">
<ImageButton Source="iconplus.png" HeightRequest="30" WidthRequest="30"></ImageButton>
</StackLayout>
In my CalendarPageViewModel.cs i already have a command that checks if if the TasksGroup exist or not and load the data if it does.
public ICommand DateChosen => new Command((obj) =>
{
var dateChosen = obj as DateTime?;
if (dateChosen != null)
{
tasksGroup = App.Database.GetTaskGroupByDate(dateChosen.Value).GetAwaiter().GetResult();
if (tasksGroup != null)
{
var data = App.Database.GetTaskByGroupId(TasksGroup.ID).GetAwaiter().GetResult();
TasksGroup = tasksGroup;
TasksGroup.Taches = data;
TasksGroup.ExpositionResult = Helper.CalculateExposition(TasksGroup);
ExpositionResult = TasksGroup.ExpositionResult;
Tasks = new ObservableCollection<Tasks>(data);
TasksGroup.Taches.ForEach(x =>
{
TaskDBA = x.TaskDBA;
TaskDuration = x.TaskDuration;
TaskDescription = x.TaskDescription;
});
}
else
{
Tasks = null;
TasksGroup = null;
ExpositionResult = null;
}
}
});
In the CalendarPage.xaml.cs i have a DateClicked function that i could use but i am unsure how to link it based on VewModel result
public void DateClicked(object sender, DateTime e)
{
PlusIconStackLayout.IsVisible = true;
}
IsVisible
to a property on your VM? – Jason