我正在按照此链接中列出的所有步骤, https://modernuicharts.codeplex.com/documentation 但它给出了以下错误,只有标题和副标题显示没有图表
严重级代码描述项目文件行抑制状态 错误' ChartBase' TargetType与元素类型不匹配 '饼图&#39 ;. MteroChartsModern c:\ users \ sesa388372 \ documents \ visual 工作室 2015 \ Projects \ MteroChartsModern \ MteroChartsModern \ Application.xaml 9
我的xaml代码:
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<chart:PieChart
Style="{StaticResource MinimalChartStyle}"
ChartTitle="Minimal Pie Chart"
ChartSubTitle="Chart with fixed width and height"
SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}" >
<chart:PieChart.Series>
<chart:ChartSeries
SeriesTitle="Errors"
DisplayMember="Category"
ValueMember="Number"
ItemsSource="{Binding Path=Errors}" />
</chart:PieChart.Series>
</chart:PieChart>
</Grid> </Window>
Application.xaml
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary >
<Style x:Key="MinimalChartStyle" TargetType="chart:ChartBase">
<Setter Property="Width" Value="500"/>
<Setter Property="Height" Value="500"/>
</Style>
</ResourceDictionary>
</Application.Resources>
答案 0 :(得分:0)
由于您要为TargetType="chart:ChartBase"
定义样式,而您使用的是chart:PieChart
,因此会出现此问题。
请为chart:PieChart
定义样式,如:
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary >
<Style x:Key="MinimalChartStyle" TargetType="chart:PieChart">
<Setter Property="Width" Value="500"/>
<Setter Property="Height" Value="500"/>
</Style>
</ResourceDictionary>
</Application.Resources>