wpf - A singleton is created when a collection-type dependency property is assigned a value -


i attempting create dependency object in wpf of type list(of) containing children of control. despite taking precautions outlined here seems singleton created when assign value property. when assign value value added multiplied number of instances of class.

here code:

public class period inherits listbox  '-------- properties --------' private property subjects() list(of subject)             return me.getvalue(subjectsproperty)     end     set(value list(of subject))         me.setvalue(subjectsproperty, value)     end set end property  private shared readonly subjectsproperty dependencyproperty = dependencyproperty.register("subjects", gettype(list(of subject)), gettype(period), new frameworkpropertymetadata(new list(of subject)))   public sub new()             mybase.new()             me.subjects = new list(of subject) 'reason: stop adding values defult value collection. see:http://msdn.microsoft.com/en-us/library/aa970563.aspx end sub 

this subroutine used refresh property when child added:

 private sub refreshsubjectsproperty()     dim listofsubjects new list(of subject)     dim subject new subject     dim entry new periodentry      each entry in logicaltreehelper.getchildren(me)         subject.subjectname = entry.subjectname         subject.teacher = entry.teacher         subject.students = entry.students          listofsubjects.add(subject)     next      me.subjects = listofsubjects end sub 


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -