我在XAML中创建了以下图表,效果很好。现在我知道它给了我我需要的东西,我现在尝试以编程方式复制结果,这样我就可以将多个实例添加到网格的不同行/列。我的VB没有错误,但没有任何显示。我有什么简单的遗失吗?
XAML:
<ComboBox Name="ComboDate" Grid.Row="1"
Background="#333333"
Foreground="#d1d1d1"
HorizontalContentAlignment="Center"/>
<chart:RadialGaugeChart Grid.Row="2"
Palette="{StaticResource CustomColors}"
VerticalAlignment="Stretch"
HorizontalAlignment="center"
Style="{StaticResource MinimalChartStyle}"
Background="#252526"
Foreground="#d1d1d1"
ChartTitle="CCO KPIs"
ChartSubTitle="Performance Towards In-Year Targets"
SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}"
Name="MyChart"
FontSize="30">
<chart:RadialGaugeChart.Series>
<chart:ChartSeries
SeriesTitle="Errors"
DisplayMember="Category"
ValueMember="Number"
ItemsSource="{Binding Path=Errors}" />
</chart:RadialGaugeChart.Series>
</chart:RadialGaugeChart>
VB:
'Create Grid Rows
Dim i As Long
For i = 1 To 3
'Create New Row
GridGauges.RowDefinitions.Add(New RowDefinition)
Next i
'Set User to the First Row
'ScrollTitle.SetValue(Grid.RowProperty, 0)
'Create Chart
Dim RadialChart As New De.TorstenMandelkow.MetroChart.RadialGaugeChart
'Set Chart to Row 2
RadialChart.SetValue(Grid.RowProperty, 0)
'Set Title
RadialChart.ChartTitle = "Test Title"
'Create Data Class for Radial Chart
Dim ChartDataClass As New TestPageViewModel()
'Set Data Context
RadialChart.DataContext = ChartDataClass
Dim RadialSeries As New De.TorstenMandelkow.MetroChart.ChartSeries
With RadialSeries
.SeriesTitle = "Error"
.DisplayMember = "Category"
.ValueMember = "Number"
.ItemsSource = ChartDataClass.Errors
End With
'Add Series to Chart
RadialChart.Series.Add(RadialSeries)
答案 0 :(得分:0)
感谢Sriram Sakthivel提供答案。我没有将图表设置为网格的子项。
解决方案:
grid.Children.Add(RadialChart)