Hosea146
Hosea146

Reputation: 7722

Can I create a template for this?

I am pretty new to WPF. I am working on a WPF based charting application. The application has roughly 20 charts. Each of the charts contains this exact same XAML in their respective XAML file:

<vf:Chart DockPanel.Dock="Top" ScrollingEnabled="False" ZoomingEnabled="True" ToolBarEnabled="True" IndicatorEnabled="{Binding Source={x:Reference DisplayIndicator}, Path=IsChecked}">

Is it possible for me to create some sort of template for this, and reference the template in each XAML file, so that if I add on to this, or change one of the properties, it's automatically reflected in all the charts?

Upvotes: 0

Views: 46

Answers (1)

Snowbear
Snowbear

Reputation: 17274

You should use Style not Templates for that:

<Resources>
    <Style TargetType="vf:Chart" x:Key="chartStyle">
        <Setter Property="ScrollingEnabled" Value="False" />
        <!-- the rest of setters here -->
    </Style>
</Resources>

...

<vf:Chart Style="{StaticResource chartStyle}" />

Upvotes: 2

Related Questions