Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / WPF

OpenWPFChart: assembling charts from components: Part I - Parts

Rate me:
Please Sign up or sign in to vote.
4.29/5 (17 votes)
19 Mar 2009CPOL14 min read 81.8K   4K   81  
Provides the component model along with base components to assemble charts.
<!--revision $Id: ChartScaleControl.xaml 18093 2009-03-16 04:15:06Z unknown $-->
<UserControl x:Class="OpenWPFChart.Helpers.ChartScaleControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:OpenWPFChart.Helpers"
	Name="chartScaleControl"
    >

	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../DialogStyle.xaml"/>
			</ResourceDictionary.MergedDictionaries>

			<DataTemplate DataType="{x:Type local:ChartNumericScaleDataView}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>

					<!-- Scale Veriety row -->
					<Label Target="{Binding ElementName=cbxScaleVeriety}">Scale Veriety</Label>
					<ComboBox Grid.Column="1" Name="cbxScaleVeriety"
						ItemsSource="{Binding Path=ScaleVerieties}"
						SelectedItem="{Binding Path=ScaleVeriety}"/>

					<!-- Start row -->
					<Label Grid.Row="1" Target="{Binding ElementName=txtStart}">Start</Label>
					<TextBox Grid.Row="1" Grid.Column="1" Name="txtStart"
						Text="{Binding Path=Start, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Stop row -->
					<Label Grid.Row="2" Target="{Binding ElementName=txtStop}">Stop</Label>
					<TextBox Grid.Row="2" Grid.Column="1" Name="txtStop"
						Text="{Binding Path=Stop, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Scale row -->
					<Label Grid.Row="3" Target="{Binding ElementName=txtScale}">Scale</Label>
					<TextBox Grid.Row="3" Grid.Column="1" Name="txtScale"
						Text="{Binding Path=Scale, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
				</Grid>
			</DataTemplate>

			<DataTemplate DataType="{x:Type local:ChartDateTimeScaleDataView}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>

					<!-- Scale Veriety row -->
					<TextBlock Margin="5, 10, 5, 5" VerticalAlignment="Center">Scale Veriety</TextBlock>
					<TextBlock Grid.Column="1" Text="{Binding Path=ScaleVeriety}" 
							   Margin="5, 10, 5, 5" VerticalAlignment="Center"/>

					<!-- Start row -->
					<Label Grid.Row="1" Target="{Binding ElementName=txtStart}">Start</Label>
					<TextBox Grid.Row="1" Grid.Column="1" Name="txtStart"
						Text="{Binding Path=Start, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Stop row -->
					<Label Grid.Row="2" Target="{Binding ElementName=txtStop}">Stop</Label>
					<TextBox Grid.Row="2" Grid.Column="1" Name="txtStop"
						Text="{Binding Path=Stop, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>

					<!-- Scale row -->
					<Label Grid.Row="3" Target="{Binding ElementName=txtScale}">Scale</Label>
					<TextBox Grid.Row="3" Grid.Column="1" Name="txtScale"
						Text="{Binding Path=Scale, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
				</Grid>
			</DataTemplate>

			<DataTemplate DataType="{x:Type local:ChartSeriesScaleDataView}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>

					<!-- Scale Veriety row -->
					<TextBlock Margin="5, 10, 5, 5" VerticalAlignment="Center">Scale Veriety</TextBlock>
					<TextBlock Grid.Column="1" Text="{Binding Path=ScaleVeriety}"
							   Margin="5, 10, 5, 5" VerticalAlignment="Center"/>

					<!-- Start row -->
					<Label Grid.Row="1" Target="{Binding ElementName=cbxStart}">Start</Label>
					<ComboBox Grid.Row="1" Grid.Column="1" Name="cbxStart"
						ItemsSource="{Binding Path=Series}"
						SelectedItem="{Binding Path=Start}"/>

					<!-- Stop row -->
					<Label Grid.Row="2" Target="{Binding ElementName=cbxStop}">Stop</Label>
					<ComboBox Grid.Row="2" Grid.Column="1" Name="cbxStop"
						ItemsSource="{Binding Path=Series}"
						SelectedItem="{Binding Path=Stop}"/>

					<!-- Scale row -->
					<Label Grid.Row="3" Target="{Binding ElementName=txtScale}">Scale</Label>
					<TextBox Grid.Row="3" Grid.Column="1" Name="txtScale"
						Text="{Binding Path=Scale, UpdateSourceTrigger=PropertyChanged,
							ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
				</Grid>
			</DataTemplate>
		</ResourceDictionary>
	</UserControl.Resources>

	<ContentControl Content="{Binding ElementName=chartScaleControl, Path=ScaleDataView}"/>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions