[C#]
private void Button_Clicked(object sender, EventArgs e)
{
var button = sender as Button;
//Storing selected appointment view to clear selection on next selection
if (!customViews.Contains(button))
customViews.Add(button);
//Clears existing selected cell
schedule.SelectedDate = null;
//Clears existing selected appointment
this.ClearSelection();
//Change Background color of selected appointment
var parentView = button.Parent as Grid;
if (parentView.BackgroundColor == Color.YellowGreen)
parentView.BackgroundColor = Color.Black;
else
parentView.BackgroundColor = Color.YellowGreen;
}
private void ClearSelection()
{
var previousSelectedView = customViews.FirstOrDefault(x => (x.Parent as Grid).BackgroundColor == Color.Black);
if(previousSelectedView != null)
(previousSelectedView.Parent as Grid).BackgroundColor = Color.YellowGreen;
} |