You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WPF Charting Toolkit PieChart绑定后不可见问题求助

问题:WPF Charting Toolkit饼图主体不显示(图例、Tooltip正常)

使用WPF Charting Toolkit展示饼图时,出现以下异常情况:

  • 饼图主体完全不可见
  • 图例可正常显示
  • 鼠标悬停饼图区域能弹出正确的工具提示

经测试,直接通过代码设置ItemsSource时饼图可正常渲染,推测问题与ItemsSource的数据绑定有关。

相关代码

XAML代码

<DVC:Chart Grid.Row="0" Padding="0" Height="160" Name="stateChart" Background="White">
    <DVC:Chart.Series>
        <DVC:PieSeries Name="stateChartPieSeries" Title="Incidence per State" 
                       ItemsSource="{Binding StatePieChartData}" 
                       IndependentValueBinding="{Binding Path=Key}" 
                       DependentValueBinding="{Binding Path=Value}" />
    </DVC:Chart.Series>
</DVC:Chart>

C#代码

构造函数部分:

public Dashboard() {
    InitializeComponent();
    model = new DashboardModel(filterReportSection.model);
    DataContext = model;

    // 取消注释这行时饼图可正常显示:
    //stateChartPieSeries.ItemsSource = model.StatePieChartData;
}

数据属性部分:

private IEnumerable statePieChartData;
public IEnumerable StatePieChartData { get { return statePieChartData; } }

GUI表现

饼图所在区域为空白,仅顶部显示图例;鼠标移至饼图对应位置时,能正常触发并显示正确的工具提示。

内容的提问来源于stack exchange,提问作者David Aigner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 19:20:20