.I am creating a user control that stacks three WPF month calendars (Master, Slave1, and Slave2) vertically. I want the second and third calendars to be hidden until the host window is large enough to show the entire month--no partial calendars. I have implemented the feature be trapping the SizeChanged event in an event handler in code-behind:
/// <summary>
/// Shows only complete calendars--partially visible calendars are hidden.
/// </summary>
private void OnSizeChanged(object sender, SizeChangedEventArgs e)
{
// Increasing window height
var newHeight = e.NewSize.Height;
if (newHeight > 500)
{
SlaveCalendar1.Visibility = Visibility.Visible;
SlaveCalendar2.Visibility = Visibility.Visible;
}
else if (newHeight > 332)
{
SlaveCalendar1.Visibility = Visibility.Visible;
SlaveCalendar2.Visibility = Visibility.Hidden;
}
else
{
SlaveCalendar1.Visibility = Visibility.Hidden;
SlaveCalendar2.Visibility = Visibility.Hidden;
}
}
It works fine, but I would rather implement the feature in XAML, and I am not sure how to do it. Any suggestions? I'm not looking for someone else to write this for me--just point me in the right direction. Thanks for your help.