I am using the charting stuff of the WPF toolkit. After creating a chart I like to have a snaphshot of that chart, without visualizing that chart. My problem is that I don't know when the rendering process is done, so I can create a snapshot. I tried listening to the "LayoutUpdated" event, but the chart 开发者_运维百科is being updated very often.
Can anyone tell me how to find out if the chart is completely rendered?
You can use the Dispatcher in your code behind:
this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
{
// code in here should be executed after chart has been rendered.
}
));
The Loaded event sounds like what you need.
MyChart.Loaded += (sender, e) =>
{
// chart has been loaded but not yet rendered
}
where "MyChart" is a the name you've given the chart in your XAML.
I'm not sure how well this works with frequent updates, but this link seems to indicate http://blogs.msdn.com/b/mikehillberg/archive/2006/09/19/loadedvsinitialized.aspx that this is what you're looking for.
精彩评论