Thursday, July 25, 2019

WPF - Difference between ContentControl and ContentPresenter?



Difference between ContentControl and ContentPresenter?


ContentPresenter is a lightweight element. It's derived from FrameworkElements class. So, It has no Template property (i.e.) we can't set control Template for it, while we can set data template for it as it has Content property.

ContentPresenter has a addition property 'ContentSource' which is not present in Content Control.

Default value of 'ContentSource' property is content, So when we will put ContentPresenter inside of ControlTemplate we don't need to define binding explicitly.

ContentControl also uses ContentPrenseter in it's template to display data.

No comments:

Post a Comment

C# Record type: Something to remember while using record types

  Record in c# provide a concise and expressive way to create immutable data types, record is a keyword in c#, we can use this keyword with ...