DataTemplate template = new DataTemplate();
FrameworkElementFactory wrapPanel = new FrameworkElementFactory(typeof(WrapPanel));
FrameworkElementFactory textBlock = new FrameworkElementFactory(typeof(TextBlock));
textBlock.SetValue(TextBlock.TextProperty, "some text");//добавим текст
wrapPanel.AppendChild(textBlock);
template.VisualTree = wrapPanel;
button.ContentTemplate = template;
Второй вариант с использованием XamlRedaer:
string temp = @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
<WrapPanel>
<TextBlock/>
</WrapPanel>
</DataTemplate>";
StringReader stringReader = new StringReader(temp);
XmlReader xmlReader = XmlReader.Create(stringReader)
DataTemplate template = XamlReader.Load(xmlReader) as DataTemplate;
button.ContentTemplate = template;
MVVM
вам не хватает...