Lets say I want to make the following a DataTemplate:
StackPanel stackPanel = new StackPanel();
Button button1 = new Button();
button1.Click += button1_Click;
Button button2 = new Button();
button2.Click += button2_Click;
stackPanel.Children.Add(button1);
stackPanel.Children.Add(button2);
How can I turn this into DataTemplate? I tried creating an instance of DataTemplate class, but I see no method or property that would let me set the stackpanel above as the content of the DataTemplate object.
EDIT: I am trying to do this in a Windows Store app.