This question is locked. New answers and comments are not allowed.
Hello,
In my project I have a need for printing the currently presented chart. I do this by simply rendering the chart into an image in memory but the on-screen colors are not fit for a white (paper) background so I need to change some of them before the rendering starts.
The chart is a RadCartesianChart and this is the part of it that declares the Horizontal axis:
As a side note I would like to mention that I have also tried the MVVM approach and bound the LabelStyle to the view model but according to this thread that is currently not possible due to a bug that is scheduled to be fixed in a later update.
So, with the above declaration refering to a static resource I later prepare the chart for hard copy rendering like this:
The 'HmiPrintedChartLabelStyle' referred to specifies a black Foreground color but the rendered chart is still rendered with its white labels. While experimenting with the chart's behavior I tried to omit the restoration of the chart LabelStyle after the hard copy rendering and it seems I cannot affect the LabelStyle at all: It's still white, even on screen, after I have changed the LabelStyle to a black font.
How do I go about changing the LabelStyle at runtime?
Thanks
In my project I have a need for printing the currently presented chart. I do this by simply rendering the chart into an image in memory but the on-screen colors are not fit for a white (paper) background so I need to change some of them before the rendering starts.
The chart is a RadCartesianChart and this is the part of it that declares the Horizontal axis:
<telerik:RadCartesianChart.HorizontalAxis> <telerik:DateTimeCategoricalAxis LabelTemplate="{StaticResource _dateTimeLabelTemplate}" LabelFitMode="Rotate" LabelStyle="{StaticResource HmiChartLabelStyle}" LineStroke="{StaticResource HmiForeColor3Brush}" > <telerik:DateTimeCategoricalAxis.MajorTickStyle> <Style TargetType="Rectangle"> <Setter Property="Fill" Value="{StaticResource HmiForeColor3Brush}" /> </Style> </telerik:DateTimeCategoricalAxis.MajorTickStyle> </telerik:DateTimeCategoricalAxis></telerik:RadCartesianChart.HorizontalAxis>As a side note I would like to mention that I have also tried the MVVM approach and bound the LabelStyle to the view model but according to this thread that is currently not possible due to a bug that is scheduled to be fixed in a later update.
So, with the above declaration refering to a static resource I later prepare the chart for hard copy rendering like this:
private static void prepareChartForRendering(RadCartesianChart chart, out object restoreState){ var chartState = new ChartState { LabelStyle = chart.HorizontalAxis.LabelStyle, PanAndZoomBehavior = chart.Behaviors.FirstOrDefault(child => child is ChartPanAndZoomBehavior) as ChartPanAndZoomBehavior }; chart.HorizontalAxis.LabelStyle = HmiResources.HmiPrintedChartLabelStyle; if (chartState.PanAndZoomBehavior != null) chart.Behaviors.Remove(chartState.PanAndZoomBehavior); restoreState = chartState;}The 'HmiPrintedChartLabelStyle' referred to specifies a black Foreground color but the rendered chart is still rendered with its white labels. While experimenting with the chart's behavior I tried to omit the restoration of the chart LabelStyle after the hard copy rendering and it seems I cannot affect the LabelStyle at all: It's still white, even on screen, after I have changed the LabelStyle to a black font.
How do I go about changing the LabelStyle at runtime?
Thanks