Thursday 15 March 2012

c# - Attached Property collection inside a Panel -


When I try to add property collection attached to a panel;

  & lt; Grid X: Name = "Main Content" grid. Line = "1" & gt; & Lt; StackPanel x: name = "main content sp" & gt; & Lt; Is: AttachCollection.Col> & Lt; Do: Attachit x = "y" /> & Lt; Do: attachite x = "z" /> & Lt; / Work: AttachCollection.Col> & Lt; TextBlock x: name = "tb1" text = "xx" /> & Lt; TextBox x: name = "TB2" text = "or" /> & lt; / StackPanel & gt; & Lt; / Grid & gt;   

This is specifying the grid instead ... How can I attach it to a panel?

It has been found that the associated property was sharing a list example with each UI element, So I had to use a laugh way instead of giving each element its list frequency. > First stable

  Dependency Property Exprotity = Dependency Property for public static reading. Registration Attached ("X", Typef (List & lt; X & gt;), Typef (X), New Property Matadata (New List & lt; X & gt; ());   

after

  public static read-only DependencyProperty XProperty = DependencyProperty .RegisterAttached -> ("XInternal", type (list & lt; X & gt;), typef (x)); - & gt; (Deleted)   

is now creating a new list example for each UI element with the recipient:

  public static list & lt; X & gt; GetX (UIElement element) {var list = ((list & lt; X & gt;) (element.GetValue (XProperty)); If (list == null) {list = new list  () ; Setx (element, list);} return list;}    

No comments:

Post a Comment