public void Render(DrawingContext drawingContext, DependencyObject o) { Visual visual = o as Visual; UIElement uiElement = o as UIElement; int popCount = 0; if (uiElement != null) { TranslateTransform translate = new TranslateTransform(uiElement.VisualOffset); drawingContext.PushTransform(translate); ++popCount; if (uiElement.Opacity != 1) { drawingContext.PushOpacity(uiElement.Opacity); ++popCount; } uiElement.OnRender(drawingContext); } if (visual != null) { for (int i = 0; i < visual.VisualChildrenCount; ++i) { this.Render(drawingContext, visual.GetVisualChild(i)); } } for (int i = 0; i < popCount; ++i) { drawingContext.Pop(); } }
public static IEnumerable GetChildren(DependencyObject current) { FrameworkElement fe = current as FrameworkElement; if (fe == null) { throw new InvalidOperationException("Object is not a FrameworkElement."); } return GetChildren(fe); }
internal virtual FrameworkElement CreateVisualTree(DependencyObject parent) { if (this.Template != null) { FrameworkElement result = this.Template.Load() as FrameworkElement; result.TemplatedParent = parent; return result; } else if (this.VisualTree != null) { FrameworkElement result = this.VisualTree.Load() as FrameworkElement; result.TemplatedParent = parent; return result; } else { throw new InvalidOperationException( "One of the Template or VisualTree properties must be set on a FrameworkTemplate."); } }
internal override void Attach(FrameworkElement target, DependencyObject parent) { DependencyObject source = parent; if (this.SourceName != null) { source = (DependencyObject)target.FindName(this.SourceName); } this.attached.Add(source, target); if (this.CheckCondition(source)) { this.Setters.Attach(target); this.applied.Add(target); } IObservableDependencyObject observable = (IObservableDependencyObject)source; observable.AttachPropertyChangedHandler(this.Property.Name, this.ValueChanged); }
private void PropagateTemplatedParent(FrameworkElement element, DependencyObject templatedParent) { element.TemplatedParent = templatedParent; foreach (FrameworkElement child in LogicalTreeHelper.GetChildren(element).OfType<FrameworkElement>()) { child.TemplatedParent = templatedParent; } }
protected internal override void OnVisualParentChanged(DependencyObject oldParent) { if (this.VisualParent != null) { this.IsInitialized = true; } }
public static void SetNameScope(DependencyObject dependencyObject, INameScope value) { dependencyObject.SetValue(NameScopeProperty, value); }
public static INameScope GetNameScope(DependencyObject dependencyObject) { return (INameScope)dependencyObject.GetValue(NameScopeProperty); }
public static DependencyObject GetParent(DependencyObject current) { FrameworkElement fe = current as FrameworkElement; return (fe != null) ? fe.Parent : null; }
public static DependencyObject FindLogicalNode(DependencyObject logicalTreeNode, string elementName) { throw new NotImplementedException(); }
public PropertyMetadata GetMetadata(DependencyObject dependencyObject) { return this.GetMetadata(dependencyObject.GetType()); }
protected void OnFreezablePropertyChanged(DependencyObject oldValue, DependencyObject newValue) { throw new NotImplementedException(); }
private bool CheckCondition(DependencyObject source) { object value = source.GetValue(this.Property); return value != null && value.Equals(ConvertToType(this.Value, this.Property.PropertyType)); }
public bool IsInstanceOfType(DependencyObject dependencyObject) { return this.SystemType.IsInstanceOfType(dependencyObject); }