I have a custom calendar control which associates text with a date, instead of a DatePicker style of control. This custom control has a class for Day with property Notes:
public string Notes
{
get { return notes; }
set
{
notes = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Notes"));
}
}
On the actual Calendar class, I have an event handler:
public event EventHandler<DayChangedEventArgs> DayChanged;
I have a Day_Changed method which triggers the event:
private void Day_Changed(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "Notes") return;
if (DayChanged == null) return;
DayChanged(this, new DayChangedEventArgs(sender as Day));
}
public class DayChangedEventArgs : EventArgs
{
public Day Day { get; private set; }
public DayChangedEventArgs(Day day)
{
this.Day = day;
}
}
And then on the actual form, I can use this created event DayChanged to trigger a method behind the form:
<PersonnelTracker:Calendar x:Name="Calendar" DayChanged="Calendar_DayChanged"/>
private void Calendar_DayChanged(object sender, DayChangedEventArgs e)
{
}
Now, what I am looking to do, is to find a way to be able to select a day or position on the calendar and trigger it to a method behind the form. The complication I am having, is that the calendar control itself doesn't have a click event, meaning one would probably have to be made, yet I can't use MouseButtonEventArgs
, due to not having an individual object to work with, such as a button.
Is there any suggestion on how best to do this?
So this is the Calendar, and for those who don't understand, I just need to click on a certain day and it to set off a click event, yet like I stated before, this calendar control doesn't have one yet, and therefore I am looking for the best possible way to create such.
The only extra details I can put forward, are that you can go through each day item in turn such like this:
foreach (Day item in Calendar.Days)
{
}