Adding DateTimeAxis in C#

Apr 28, 2009 at 5:05 AM
Hi,

How can I translate this code from Xaml to C# to add DateTimeAxis?

Thanks,
Kamel

<Window x:Class="CurrencyExchangeSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:c="http://research.microsoft.com/DynamicDataDisplay/1.0"
    Title="Window1" WindowState="Maximized">
	<Grid>
		<c:ChartPlotter Name="plotter">
			<c:ChartPlotter.HorizontalAxis>
				<c:HorizontalDateTimeAxis Name="dateAxis"/>
			</c:ChartPlotter.HorizontalAxis>
		</c:ChartPlotter>
	</Grid>
</Window>
Editor
Apr 28, 2009 at 8:57 AM
Hi, Kamel,

You should write the following C#-code:

            HorizontalDateTimeAxis dateAxis = new HorizontalDateTimeAxis();

            plotter.HorizontalAxis = dateAxis;


This code (both XAML and C#) doesn't actually add an axis, it replaces existing horizontal axis with that you've specified.
To add another axis without removing existing one, you should create an axis and then call 
plotter.Children.Add(your_additional_axis);

Mikhail.
Apr 30, 2009 at 2:13 AM
Thanks Mikhail, it's working great.