Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF: Inheriting from HeaderedContentControl
    primarykey
    data
    text
    <p>I would like to create a simple control that inherits from HeaderedContentControl, and has some basic dependency properties called Title, Subtitle, Icon. I would like to be able to provide a default header template that databinds these properties. For this example, I have named this class HeaderedView.</p> <p>I am having trouble in providing a default header template that can bind to the properties defined on the HeaderedView. I am experimenting with markup like the following:</p> <pre><code>&lt;Style TargetType="{x:Type local:HeaderedView}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type HeaderedContentControl}"&gt; &lt;StackPanel&gt; &lt;Grid&gt; &lt;ContentPresenter ContentSource="Header"/&gt; &lt;/Grid&gt; &lt;Grid&gt; &lt;ContentPresenter ContentSource="Content"/&gt; &lt;/Grid&gt; &lt;/StackPanel&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="HeaderTemplate"&gt; &lt;Setter.Value&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;TextBlock Text="{TemplateBinding local:HeaderedView.Title}" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Unfortunately, the Title is not being displayed.</p> <p>The header template must be replaceable (which is why I want to utilize the HeaderedContentControl).</p> <p>Every time I seem to want to inherit from this control, I seem to struggle with the implementation. Any help would be greatly appreciated! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload