我遇到了 LiveCharts:PieMenu 的问题。我在资源文件上定义了 PieChart 和 PieSeries 的样式,以便我所有的饼图看起来都一样。在 UserControl 中,我使用资源字典中的资源文件并将其添加到资源中,然后创建 2 个饼图:
<Border HorizontalAlignment="Stretch"
Background="{StaticResource MenuBackgroundScb2}"
BorderThickness="2" BorderBrush="{StaticResource WidgetBorderScb}"
Margin="0 0 0 20">
<StackPanel HorizontalAlignment="Stretch" >
<Label Content="Montant des offres selon leurs états" Style="{StaticResource TitleLabel}"/>
<lc:PieChart Series="{Binding Path=AmountOfferByStatusSeriesCollection}"/>
</StackPanel>
</Border>
<Border HorizontalAlignment="Stretch"
Background="{StaticResource MenuBackgroundScb2}"
BorderThickness="2" BorderBrush="{StaticResource WidgetBorderScb}">
<StackPanel HorizontalAlignment="Stretch" >
<Label Content="Nombre d'offres selon leurs états" Style="{StaticResource TitleLabel}"/>
<lc:PieChart Series="{Binding Path=NbOfferByStatusSeriesCollection}" />
</StackPanel>
</Border>
第一个图表饼图看起来不错,但第二个饼图有问题:图例未显示,鼠标悬停会使应用程序崩溃。
该错误出现是因为我在单独的资源文件中而不是在 PieChart 的资源中声明了样式,所以我知道 Series NbOfferByStatusSeriesCollection 没有问题。
此外,我有第三个饼图,它显示在另一个页面中,与前两个不同,而且这个饼图工作正常。
我做错了什么??
这是资源文件的摘录。
<Style TargetType="lc:PieChart">
<Setter Property="Height" Value="140"/>
<Setter Property="InnerRadius" Value="25"/>
<Setter Property="SeriesColors" Value="{StaticResource GraphColors}" />
<Setter Property="Foreground" Value="{StaticResource LightForegroundScb}"/>
<Setter Property="LegendLocation" Value="Right" />
<Setter Property="ChartLegend">
<Setter.Value>
<lc:DefaultLegend BulletSize="20"/>
</Setter.Value>
</Setter>
<Setter Property="DataTooltip">
<Setter.Value>
<lc:DefaultTooltip SelectionMode="OnlySender"
Foreground="{StaticResource LightForegroundScb}"
Background="{StaticResource MenuBackgroundScb2}"
BorderThickness="2"
BorderBrush="{StaticResource MenuBackgroundScb}"
BulletSize="20" />
</Setter.Value>
</Setter>
</Style>
<Style TargetType="lc:PieSeries">
<Setter Property="Stroke" Value="{StaticResource MenuBackgroundScb2}"/>
<Setter Property="StrokeThickness" Value="3"/>
</Style>
这是调用堆栈: