1
我相信我正在使用Silverlight 3.0 ......本週我剛剛下載了它。假設圖表命名空間引用System.Windows.Controls.DataVisualization assembly in the Silverlight Toolkit,請幫我用C#創建DataPointStyle,因爲它在XAML中所表達如下:Silverlight:在C#中定義一個自定義ControlTemplate而不是XAML
<charting:Chart
Title="Simple Column Annotations - Bottom">
<charting:ColumnSeries
DependentValuePath="Value"
IndependentValuePath="Key"
ItemsSource="{Binding}">
<!-- HERE IS WHAT I WANT TO CREATE IN C#: -->
<charting:ColumnSeries.DataPointStyle>
<Style TargetType="charting:ColumnDataPoint">
<Setter Property="Background" Value="Yellow"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:ColumnDataPoint">
<Grid>
<Rectangle
Fill="{TemplateBinding Background}"
Stroke="Black"/>
<Grid
Background="#aaffffff"
Margin="0 -20 0 0"
HorizontalAlignment="Center"
VerticalAlignment="Bottom">
<TextBlock
Text="{TemplateBinding FormattedDependentValue}"
FontWeight="Bold"
Margin="2"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:ColumnSeries.DataPointStyle>
<!-- END -->
</charting:ColumnSeries>
</charting:Chart>
我的目標是打造易於使用的模板庫,可應用於系列在圖表中。謝謝!
啊,我明白了 - 謝謝。我將把XAML放入資源字典中。 – 2010-01-01 20:50:10