本文介绍了wpf图表打印(system.windows.controls.datavisualization.toolkit)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF / C#项目的system.windows.controls.datavisualization.toolkit中使用了一个条形图。我想在一个页面上打印此图表,但它似乎没有任何绑定在打印之前执行。



我的XAML代码看起来像这样(我已经省略了布局的东西)

 < Grid x:Name =LayoutRoot> 
< chartingToolkit:图表x:Name =GUIchartStyle ={StaticResource TheGUIChartStyle}FontSize =12>
< chartingToolkit:BarSeries x:Name =SeriesItemsSource ={Binding}>
< chartingToolkit:BarSeries.DependentRangeAxis>
< chartingToolkit:LinearAxis x:Name =XaxisMinimum =0Maximum =100Interval =10ShowGridLines =TrueOrientation =X/>
< / chartingToolkit:BarSeries.DependentRangeAxis>
< / chartingToolkit:BarSeries>
< / chartingToolkit:图表>
< / Grid>





一些标题和绑定:

  //设置X轴标题
Xaxis.Title = ;

//进行绑定
Series.IndependentValuePath =Name;
Series.DependentValuePath =Score;
Series.ItemsSource = scores;

调试时,实际上在将图表添加到页面之前执行此绑定。

解决方案

这是一个可能的原因,默认的淡入动画在图表。在中进行了说明。您应该能够从源代码复制默认图表样式并注释掉VSM动画。



您可以下载最新的DataVisualization开发版本的源代码。一旦你有源,你想要看的文件是在Core.WPF项目 - Themes \Generic.xaml。



我没有真正尝试过,但你应该能够复制BarDataPoint样式并删除RevealStatesVisualStateGroup。 p>

I'm using a Bar Chart in the system.windows.controls.datavisualization.toolkit in a WPF/C# project. I would like to print this chart on a page, but it appears none of the binding are executed before printing. I end up with an empty square where the chart should be.

My XAML code looks like this (I've ommitted layout things)

<Grid x:Name="LayoutRoot">
    <chartingToolkit:Chart x:Name="GUIchart" Style="{StaticResource TheGUIChartStyle}" FontSize="12">
        <chartingToolkit:BarSeries x:Name="Series" ItemsSource="{Binding}">
            <chartingToolkit:BarSeries.DependentRangeAxis>
                <chartingToolkit:LinearAxis x:Name="Xaxis" Minimum="0" Maximum="100" Interval="10" ShowGridLines="True" Orientation="X"/>
            </chartingToolkit:BarSeries.DependentRangeAxis>
        </chartingToolkit:BarSeries>
    </chartingToolkit:Chart>
</Grid>

In c# I'm adding some titels and the bindings:

// set the X-axis title
Xaxis.Title = "Score in %";

// do the binding
Series.IndependentValuePath = "Name";
Series.DependentValuePath = "Score";
Series.ItemsSource = scores;

When debugging, this binding is actually executed before the chart is being add to the page. Nevertheless, I end up with an "empty" chart.

解决方案

One possible cause for this the default fade-in animation in the chart. It is described in this forum post. You should be able to copy the default chart style from the source code and comment out the VSM animation.

You can download the source code for the latest DataVisualization development release here. Once you have the source, the file you want to look at is in the Core.WPF project - Themes\Generic.xaml. All the styles can be found there.

I have not actually tried it, but you should be able to copy the BarDataPoint style and remove the "RevealStates" VisualStateGroup.

这篇关于wpf图表打印(system.windows.controls.datavisualization.toolkit)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 08:46