Live Chat Icon For mobile
Live Chat Icon

How can I define a style for a ContentControl to give it a meaningful appearance in the UI ?

Platform: WPF| Category: Templates

This can be done as follows.


<Style x:Key='ContentCtrl' TargetType='ContentControl'>
    <Setter Property='Background' Value='Red'/>
    <Setter Property='Foreground' Value='Green'/>
    <Setter Property='FontSize' Value='20'/>
    <Setter Property='FontWeight' Value='Bold'/>
    <Setter Property='Template'>
            <ControlTemplate TargetType='ContentControl'>
                    <Ellipse Width='{TemplateBinding Width}' Height='{TemplateBinding Width}' Fill='{TemplateBinding Background}'/>
                    <ContentPresenter VerticalAlignment='Center' HorizontalAlignment='Center'/>


<ContentControl Width='75' Height='100' Style='{StaticResource ContentCtrl}' Content='Hello'/>

Share with

Related FAQs

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

Please submit your question and answer.