2012-02-04 93 views
0

我是WPF的新手。我正在开发基于WPF的图表应用程序。该应用程序大约有20个图表。每个图都包含在各自的XAML文件,这完全一样的XAML:我可以为此创建模板吗?

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

是否有可能对我来说,建立某种形式的模板,这一点,并在每个XAML文件中引用模板,所以如果我添加对此,还是更改其中一个属性,它会自动反映到所有图表中?

回答

2

您应该使用StyleTemplates为:

<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}" /> 
相关问题