public void ShouldAssignDataContextWithProvidedItem() { PropertyContainer container = new PropertyContainer(); GridEntry item = new GridEntryMock(); new PropertyItemsLayoutMock().CallPrepareContainerForItemOverride(container, item); Assert.AreEqual(item, container.DataContext); }
public void ShouldAssignBindingWithProvidedItem() { PropertyContainer container = new PropertyContainer(); GridEntry item = new GridEntryMock(); new PropertyItemsLayoutMock().CallPrepareContainerForItemOverride(container, item); var expression = container.GetBindingExpression(GridEntryContainer.EntryProperty); Assert.IsNotNull(expression); }
/// <summary> /// Gets the tab element on which the focus can be placed. /// </summary> /// <remarks> /// If an element is not enabled it will not be returned. /// </remarks> /// <param name="source">The source.</param> /// <param name="delta">The delta.</param> private UIElement GetTabElement(DependencyObject source, int delta) { if (source == null) { return(null); } PropertyContainer container = null; if (source is SearchTextBox && HasCategories) { var itemspres = FindVisualChild <ItemsPresenter>(this); if (itemspres != null) { var catcontainer = FindVisualChild <CategoryContainer>(itemspres); if (catcontainer != null) { container = FindVisualChild <PropertyContainer>(catcontainer); } } } else { container = FindVisualParent <PropertyContainer>(source); } var spanel = FindVisualParent <StackPanel>(container); if (spanel != null && spanel.Children.Contains(container)) { var index = spanel.Children.IndexOf(container); if (delta > 0) { index = (index == spanel.Children.Count - 1) ? 0 : index + delta;//go back to the first after last } else { index = (index == 0) ? spanel.Children.Count - 1 : index + delta;//go to last after first } //loop inside the list if (index < 0) { index = spanel.Children.Count - 1; } if (index >= spanel.Children.Count) { index = 0; } var next = VisualTreeHelper.GetChild(spanel, index) as PropertyContainer;//this has always a Grid as visual child var grid = FindVisualChild <Grid>(next); if (grid != null && grid.Children.Count > 1) { var pecp = grid.Children[1] as PropertyEditorContentPresenter; var final = VisualTreeHelper.GetChild(pecp, 0); if ((final as UIElement).IsEnabled && (final as UIElement).Focusable && !(next.DataContext as PropertyItem).IsReadOnly) { return(final as UIElement); } else { return(GetTabElement(final, delta)); } } } return(null); }
public void ShouldAssignItselfAsParentContainer() { PropertyContainer container = new PropertyContainer(); Assert.AreEqual(container, PropertyContainer.GetParentContainer(container)); }