private static void element_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var element = (UIElement)sender; // find the ReoderListBox parent of the element var reorderListBox = TreeHelpers.FindParent <ReorderListBox>(element); if (reorderListBox != null) { // find the ItemContainer FrameworkElement f = TreeHelpers.GetItemContainerFromChildElement(reorderListBox, element) as FrameworkElement; if (f != null) { reorderListBox.BeginDrag(f); } } }
private void onPreApplyTemplate() { if (!m_appliedTemplate) { m_appliedTemplate = true; DependencyObject source = base.TemplatedParent; if (source is ItemsPresenter) { source = TreeHelpers.FindParent <ItemsControl>(source); } if (source != null) { bindToParentItemsControl(ItemHeightProperty, source); bindToParentItemsControl(ItemWidthProperty, source); } } }