Can I create a ContentTemplate and apply the template to a ContentControl ?

Platform: WPF| Category: Templates

The following code shows how the content template can be created and applied to a content control.

[XAML]
<DataTemplate x:Key='template1'>
  <TextBlock Text='{Binding}' FontSize='12' FontWeight='Bold' TextWrapping='Wrap'></TextBlock>
</DataTemplate>

The above code can be applied as follows.

[XAML]

<Button ContentTemplate='{StaticResource template1}' Content='Click'>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.