Click here to Skip to main content
15,884,041 members
Articles / Desktop Programming / WPF

OpenWPFChart: Assembling Charts from Components. Part II - Controls

Rate me:
Please Sign up or sign in to vote.
4.90/5 (14 votes)
26 Mar 2009CPOL10 min read 69.6K   2.2K   52  
Chart controls composed from Chart Parts
<!--revision $Id: dlgChartScales.xaml 18093 2009-03-16 04:15:06Z unknown $-->
<Window x:Class="WellLogSample.dlgChartScales"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:WellLogSample"
	WindowStartupLocation="CenterOwner"
	FocusManager.FocusedElement="{Binding ElementName=txtDepthScale}"
	SizeToContent="WidthAndHeight" ResizeMode="NoResize"
	Title="Chart Scales"
	BorderBrush="Cornsilk" BorderThickness="15" 
	Background="AliceBlue">

	<Window.Resources>
		<Style TargetType="Label">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Padding" Value="5" />
		</Style>
		<Style TargetType="Button">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Margin" Value="5, 10, 5, 5" />
		</Style>
		<Style x:Key="dialogButton" TargetType="Button">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Margin" Value="5, 10, 5, 5" />
			<Setter Property="Width" Value="72" />
		</Style>
		<Style TargetType="{x:Type TextBox}">
			<Setter Property="Validation.ErrorTemplate">
				<Setter.Value>
					<ControlTemplate>
						<DockPanel LastChildFill="True">
							<TextBlock DockPanel.Dock="Right" Foreground="Red"
								FontSize="16" FontWeight="Bold"
								ToolTip="{Binding ElementName=adornerPlaceholder, 
									Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
								Text=" !"/>
							<Border BorderBrush="Red" BorderThickness="2">
								<AdornedElementPlaceholder Name="adornerPlaceholder"/>
							</Border>
						</DockPanel>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</Window.Resources>
	
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition Width="Auto"/>
		</Grid.ColumnDefinitions>

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

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

		<!-- Dialog buttons row -->
		<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal" 
					HorizontalAlignment="Right" VerticalAlignment="Bottom">
			<Button Name="btnOK" Click="btnOK_Click"  Style="{StaticResource dialogButton}" IsDefault="True" IsEnabled="False">OK</Button>
			<Button Style="{StaticResource dialogButton}" IsCancel="True">Cancel</Button>
		</StackPanel>
	</Grid>
</Window>

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