How do I save the date picker to the calendar?
I have created code that reads dates from a database and puts them in a Calendar control. Everything works well, but if the user selects a date in the calendar, after population, the entire date selected with the code disappears. Is there another way to mark a date that was previously added from the database?
public void setFixturesControl()
{
Database.m_dbConnection.Open();
string query = "select * from date";
SQLiteCommand input = new SQLiteCommand(query, Database.m_dbConnection);
SQLiteDataReader reader = input.ExecuteReader();
while (reader.Read())
{
if (MainWindow.AppWindow.League.SelectedItem.ToString().Equals(reader["caption"].ToString()))
{
MainWindow.AppWindow.Calendar.SelectedDates.Add(DateTime.Parse(reader["data"].ToString()));
}
}
Database.m_dbConnection.Close();
}
Is there a way to prevent dates from disappearing after user clicks? Or something that lets me know the dates added by the population of the database? Thank.
source to share
After a lot of searching the net and a lot of documentation in the Calendar class, I could see two things:
- To get what I want, I have to use a custom control
- Try to work through the code by creating a delegate, but this is not exactly an easy thing
In the first case I ran, in particular, from the post of David Vinmena, he just solve my problem. The final result will be like this:
Exactly what I want.
Everything is documented in the post, so it would be pointless to make a copy here. Thanks to this member for at least getting me to fix the Microsoft control issue. Unfortunately, I am becoming more and more convinced that WPF is still immature, and it still takes a few years for that. I hope my answer helps if anyone can solve the problem more elegantly, responds well. Thank.
source to share