Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this:</p> <pre><code>private void Window_ContentRendered(object sender, EventArgs e) { // Find the Popup in template Popup MyPopup = FindChild&lt;Popup&gt;(MyDatePicker, "PART_Popup"); // Get Calendar in child of Popup Calendar MyCalendar = (Calendar)MyPopup.Child; // For test MyCalendar.BlackoutDates.Add(new CalendarDateRange( new DateTime(2013, 8, 1), new DateTime(2013, 8, 10) )); } </code></pre> <p><strong><code>Note:</code></strong> Always use <code>FindChild</code> only when the control will be fully loaded, otherwise it will not find it and give <em>null</em>. In this case, I put this code in the event <code>ContentRendered</code> of <code>Window</code> which says that all the contents of the window successfully load.</p> <p>Listing of <code>FindChild&lt;&gt;</code>:</p> <pre><code> public static T FindChild&lt;T&gt;(DependencyObject parent, string childName) where T : DependencyObject { if (parent == null) { return null; } T foundChild = null; int childrenCount = VisualTreeHelper.GetChildrenCount(parent); for (int i = 0; i &lt; childrenCount; i++) { var child = VisualTreeHelper.GetChild(parent, i); T childType = child as T; if (childType == null) { foundChild = FindChild&lt;T&gt;(child, childName); if (foundChild != null) break; } else if (!string.IsNullOrEmpty(childName)) { var frameworkElement = child as FrameworkElement; if (frameworkElement != null &amp;&amp; frameworkElement.Name == childName) { foundChild = (T)child; break; } else { foundChild = FindChild&lt;T&gt;(child, childName); if (foundChild != null) { break; } } } else { foundChild = (T)child; break; } } return foundChild; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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