Windows phone7 dynamic add control
Using system;
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. net;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. documents;
Using system. Windows. input;
Using system. Windows. Media;
Using system. Windows. Media. animation;
Using system. Windows. shapes;
Using Microsoft. Phone. controls;
Namespace testbywgscd
{
Public partial class mainpage: phoneapplicationpage
{
// Constructor
Public mainpage ()
{
Initializecomponent ();
}
Private void button#click (Object sender, routedeventargs E)
{
For (INT I = 0; I <5; I ++)
{
VaR checkbox = new checkbox
{
Content = "inbox ",
Horizontalalignment = horizontalalignment. Left,
Verticalalignment = verticalignment. Top,
Fontfamily = new fontfamily ("calibri "),
Fontsize = 30,
Margin = New thickness (11, I * 101,0, 0 ),
Length = 101,
Height = 101,
};
Checkbox. Checked + = new routedeventhandler (checkbox_checked );
Contentpanel. Children. Add (checkbox); // contentpanel is Grid Control
// Frameworkdispatcher. Update ();
// Grid. setrow (checkbox, I + 10 );
// Grid. setrow (checkbox, I + 10 );
}
}
Void checkbox_checked (Object o, routedeventargs e ){
MessageBox. Show ("hello6 ");
}
}
}