Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For your DatePicker dilemma, I found a neat hack using attached properties (modified from my use of CommandBindings):</p> <pre><code>class AttachedProperties : DependencyObject { #region RegisterBlackoutDates // Adds a collection of command bindings to a date picker's existing BlackoutDates collection, since the collections are immutable and can't be bound to otherwise. // // Usage: &lt;DatePicker hacks:AttachedProperties.RegisterBlackoutDates="{Binding BlackoutDates}" &gt; public static DependencyProperty RegisterBlackoutDatesProperty = DependencyProperty.RegisterAttached("RegisterBlackoutDates", typeof(System.Windows.Controls.CalendarBlackoutDatesCollection), typeof(AttachedProperties), new PropertyMetadata(null, OnRegisterCommandBindingChanged)); public static void SetRegisterBlackoutDates(UIElement element, System.Windows.Controls.CalendarBlackoutDatesCollection value) { if (element != null) element.SetValue(RegisterBlackoutDatesProperty, value); } public static System.Windows.Controls.CalendarBlackoutDatesCollection GetRegisterBlackoutDates(UIElement element) { return (element != null ? (System.Windows.Controls.CalendarBlackoutDatesCollection)element.GetValue(RegisterBlackoutDatesProperty) : null); } private static void OnRegisterCommandBindingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { System.Windows.Controls.DatePicker element = sender as System.Windows.Controls.DatePicker; if (element != null) { System.Windows.Controls.CalendarBlackoutDatesCollection bindings = e.NewValue as System.Windows.Controls.CalendarBlackoutDatesCollection; if (bindings != null) { element.BlackoutDates.Clear(); foreach (var dateRange in bindings) { element.BlackoutDates.Add(dateRange); } } } } #endregion } </code></pre> <p>I'm sure I'm too late to help you out, but hopefully someone else will find it useful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload