//dynamically drawing the values in a Grid layout control in WPF requires that the number of fields in the class be dynamically generated to generate the number of grid columns or the number of rows, Public classModels { PublicLabel name {Get;Set; } PublicLabel Age {Get;Set; } PublicGifimage gif {Get;Set; } PublicImage img {Get;Set; } PublicButton BTN {Get;Set; } }
//This is the class that needs to be reflected, mostly by code to get all the fields in the classType T =typeof(models);//gets the type of the class//a collection of fields in a classPropertyinfo[] Info = t.getproperties (bindingflags.public |bindingflags.instance); foreach(PropertyInfo Iinchinfo) { stringname = I.name;//get the name of a field in a class//clomn = new ColumnDefinition (); //grid. Columndefinitions.add (CLOMN); }//***over//********************************* //reflect all PropertiesType T =typeof(models); Methodinfo[] Info=T.getmethods (); foreach(MethodInfo Iinchinfo) { }
C # Reflection class fields