I want to write a custom framework element that hosts the visuals. My first attempt was to create an example of ContainerVision and write a Cover property for ContainerVision. Children and then set it as ContentProperty so that I can make a visual through XAML. But visual collection only implements iClust or iiList or any supported interface and visual code is not celidated, so I can not apply myself to ILIL.
How can I add host visitors and declarations using them using XAML?
OK, long time ago, but I got this solution back at that time ...
Archive: Note the hack comments.
using the system; Using System.Collections.Generic; Using System.Linq; Using System.Text; System.Windows.Media; Using System.Collections.ObjectModel; Using WPF.Controls.Primitives; Namespace WPF.Controls.Core {Public Class PrimitiveCollection: Observational Collection & lt; Primitive & gt; {Protected PrimitiveContainerVisual _owner; Public PrimitiveCollection (PrimitiveContainerVisual Owner): Base () {If (Owner == blank) Repeat new logic ("Owner"); _owner = owner; } Safe override zero explicit animations () {foreach (different items in this) {item.IsDirtyChanged - = New IsDirtyChangedHandler (item_IsDirtyChanged); _owner.InternalRemoveVisualChild (item); } Base.ClearItems (); } Secure Override Zero InsertItem (Int Indexes, Primitive Object) {If (item! = Faucet & Item. Original! = Faucet) Throw new logic NullException ("Visual is original"); Item.IsDirtyChanged + = New IsDirtyChangedHandler (item_IsDirtyChanged); _owner.InternalAddVisualChild (item); Base.InsertItem (index, item); } Secure Override Zero Remove althetime (int index) {primitive object = this [index]; Item.IsDirtyChanged - = New IsDirtyChangedHandler (item_IsDirtyChanged); _owner.InternalRemoveVisualChild (item); Base.RemoveItem (index); } Secure Override Zero OnPropertyChanged (System.ComponentModel.PropertyChangedEventArgs e) {base.OnPropertyChanged (e); } Zero object_isis color color (object sender, primitive change event events e) {if (e.IsDirty) _owner.RequestRedraw (); }}
and the controls you can use in XAML
using the system; Using System.Collections.Generic; Using System.Linq; Using System.Text; System.Windows.Media; Using WPF.Controls.Primitives; Using System.Windows; Using the system. Namespace WPF.Controls.Core {PUBLIC CLASS PrimitiveContainerVisual: Visual {Private PrimitiveCollection _primitives; Private PropertyInfo _contentBoundsPropInfo; Private PropertyInfo _descendantBoundsPropInfo; Public Primitive Select Children ({return_primety;} set {_primitives = value;}} Get the Internal Asset of Hack Reset {// Hack Access _contentBoundsPropInfo.GetValue (this, empty);}} Public Reich Disconnects {// Get the view of the internal property of Hack Access {Return (Rect) _descendantBoundsPropInfo.GetValue (this, empty);}} Public PrimitiveContainerVisual () {_primitives = New Primitive Collection (); Type this = this.GetType (); Binding F Lags = binding flag. Nonpolic | BindingFlags.Instance; _contentBoundsPropInfo = thisType.GetProperty ("Visual contentBand", flags); _descendantBoundsPropInfo = thisType.GetProperty ("VisualDanceband", Flags);} Internal Zero Internal Advil Chain (Primitive etc.) {this. AddVisualChild ();} Internal Zero InternalRemoveVisualChild (Primitive Prime) {this.RemoveVisualChild (Prime);} Public bool RequestRedraw () {Visualized as UIElement uiParent = UIElement; if (uiParent! = Null) {uiParent.InvalidateVisual ); Return true; } And false return; }}}
Comments
Post a Comment