All the controls missing in WPF. Over 1 million downloads.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
12 KiB

<!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<sample:DemoView x:Class="Samples.Modules.Numeric.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sample="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:Samples.Modules.Numeric.Views"
Title="Numeric Controls"
x:Name="_demo">
<sample:DemoView.Resources>
<x:Array x:Key="FormatStringComboBox" Type="local:FormatObject">
<local:FormatObject Value="C2" DisplayValue="Currency" />
<local:FormatObject Value="F2" DisplayValue="Fixed Point" />
<local:FormatObject Value="G" DisplayValue="General" />
<local:FormatObject Value="N" DisplayValue="Number" />
<local:FormatObject Value="P2" DisplayValue="Percent" />
</x:Array>
<DataTemplate x:Key="FormatStringItemTemplate">
<TextBlock Text="{Binding DisplayValue}" />
</DataTemplate>
<ObjectDataProvider x:Key="AllowInputSpecialValuesComboBox" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="xctk:AllowedSpecialValues" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="ParsingNumberStyleComboBox" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sys:Globalization.NumberStyles" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<Style x:Key="ControlInError" TargetType="Control">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors).CurrentItem.ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
<sys:String x:Key="allowInputSpecialValuesTooltip">Infinity and -Infinity input will not be accepted if Maximum and/or Minimum values does not allow them.</sys:String>
<sys:String x:Key="parsingNumberStyleTooltip">HexNumber is not a valid choice when used with a DoubleUpDown (current control used in this sample). It will work with the following controls: IntegerUpDown, ByteUpDown, LongUpDown, and ShortUpDown.</sys:String>
</sample:DemoView.Resources>
<StackPanel>
<RichTextBox IsReadOnly="True" BorderThickness="0">
<FlowDocument>
<Paragraph>
Numeric up-down controls provide a TextBox with button spinners that allow incrementing
and decrementing numeric values by using the spinner buttons, keyboard up/down arrows, or mouse wheel.
</Paragraph>
<Paragraph>
The following controls are available to support various native numeric types:
ByteUpDown, ShortUpDown, IntegerUpDown, LongUpDown, SingleUpDown, DoubleUpDown, DecimalUpDown.
</Paragraph>
</FlowDocument>
</RichTextBox>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<GroupBox Header="Features" Grid.Row="0" Margin="5">
<Grid Margin="5" HorizontalAlignment="Left">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- 1st column -->
<TextBlock Text="Allow Input Special Values:" VerticalAlignment="Center" />
<ComboBox Grid.Column="1" ItemsSource="{Binding Source={StaticResource AllowInputSpecialValuesComboBox}}" SelectedValue="{Binding AllowInputSpecialValues, ElementName=_doubleUpDown}" ToolTip="{StaticResource allowInputSpecialValuesTooltip}" Margin="5" Width="108"/>
<TextBlock Text="Mouse Wheel:" Grid.Row="1" VerticalAlignment="Center" />
<CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding MouseWheelActiveOnFocus, ElementName=_doubleUpDown}" ClickMode="Press" Margin="5" VerticalAlignment="Center" />
<TextBlock Text="Show Button Spinner:" Grid.Row="2" VerticalAlignment="Center" />
<CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding ShowButtonSpinner, ElementName=_doubleUpDown}" ClickMode="Press" Margin="5" VerticalAlignment="Center" />
<TextBlock Text="Allow Spin:" Grid.Row="3" VerticalAlignment="Center" />
<CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding AllowSpin, ElementName=_doubleUpDown}" ClickMode="Press" Margin="5" VerticalAlignment="Center" />
<TextBlock Text="Is Read Only:" Grid.Row="4" VerticalAlignment="Center" />
<CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding IsReadOnly, ElementName=_doubleUpDown}" ClickMode="Press" Margin="5" VerticalAlignment="Center" />
<!-- 2nd column -->
<TextBlock Grid.Column="2" Text="CultureInfo:" VerticalAlignment="Center" Margin="10,0,0,0" />
<ComboBox Grid.Column="3" ItemsSource="{Binding Cultures, ElementName=_demo}" SelectedValue="{Binding CultureInfo, ElementName=_doubleUpDown}" Width="65" Margin="5" />
<TextBlock Grid.Column="2" Grid.Row="1" Text="FormatString:" VerticalAlignment="Center" Margin="10,0,0,0"/>
<ComboBox Grid.Column="3" Grid.Row="1" ItemsSource="{Binding Source={StaticResource FormatStringComboBox}}" Text="{Binding FormatString, ElementName=_doubleUpDown, ValidatesOnExceptions=True}" ItemTemplate="{StaticResource FormatStringItemTemplate}" Style="{StaticResource ControlInError}" IsEditable="True" TextSearch.TextPath="Value" Width="65" Margin="5" />
<TextBlock Grid.Column="2" Grid.Row="2" Text="Increment" VerticalAlignment="Center" Margin="10,0,0,0"/>
<xctk:DoubleUpDown Grid.Column="3" Grid.Row="2" Minimum="0" Value="{Binding Increment, ElementName=_doubleUpDown}" AllowInputSpecialValues="None" VerticalAlignment="Center" Margin="5" Width="65" />
<TextBlock Grid.Column="2" Grid.Row="3" Text="Minimum" VerticalAlignment="Center" Margin="10,0,0,0"/>
<xctk:DoubleUpDown Grid.Column="3" Grid.Row="3" Value="{Binding Minimum, ElementName=_doubleUpDown}" AllowInputSpecialValues="NegativeInfinity" VerticalAlignment="Center" Margin="5" Width="65" />
<TextBlock Grid.Column="2" Grid.Row="4" Text="Maximum" VerticalAlignment="Center" Margin="10,0,0,0"/>
<xctk:DoubleUpDown Grid.Column="3" Grid.Row="4" Value="{Binding Maximum, ElementName=_doubleUpDown}" AllowInputSpecialValues="PositiveInfinity" VerticalAlignment="Center" Margin="5" Width="65" />
<!-- 3rd column -->
<TextBlock Grid.Column="4" Text="ParsingNumberStyle:" VerticalAlignment="Center" Margin="10,0,0,0"/>
<ComboBox Grid.Column="5" ItemsSource="{Binding Source={StaticResource ParsingNumberStyleComboBox}}" SelectedValue="{Binding ParsingNumberStyle, ElementName=_doubleUpDown}" ToolTip="{StaticResource parsingNumberStyleTooltip}" Width="135" Margin="5" />
<TextBlock Text="Watermark:" Grid.Column="4" Grid.Row="1" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBox Grid.Column="5" Grid.Row="1" Width="135" Margin="5" Text="{Binding Watermark, ElementName=_doubleUpDown}" />
<TextBlock Text="Default Value:" Grid.Column="4" Grid.Row="2" VerticalAlignment="Center" Margin="10,0,0,0"/>
<xctk:DoubleUpDown Grid.Column="5" Grid.Row="2" Value="{Binding DefaultValue, ElementName=_doubleUpDown}" AllowInputSpecialValues="Any" VerticalAlignment="Center" Margin="5" Width="135" />
<TextBlock Text="Value:" Grid.Column="4" Grid.Row="3" VerticalAlignment="Center" Margin="10,0,0,0"/>
<xctk:DoubleUpDown Grid.Column="5" Grid.Row="3" Value="{Binding Value, ElementName=_doubleUpDown, ValidatesOnExceptions=True}" AllowInputSpecialValues="Any" Style="{StaticResource ControlInError}" VerticalAlignment="Center" Margin="5" Width="135" />
<TextBlock Text="Text:" Grid.Column="4" Grid.Row="4" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBox Grid.Column="5" Grid.Row="4" Text="{Binding Text, ElementName=_doubleUpDown}" VerticalAlignment="Center" Margin="5" Width="135" />
</Grid>
</GroupBox>
<StackPanel Grid.Row="1" Margin="10" HorizontalAlignment="Left">
<TextBlock Text="Usage:" Style="{StaticResource Header}" />
<xctk:DoubleUpDown x:Name="_doubleUpDown"
Margin="10" Width="250"
AllowInputSpecialValues="Any"
ShowButtonSpinner="True"
AllowSpin="True"
IsReadOnly="False"
MouseWheelActiveOnFocus="True"
CultureInfo="en-US"
FormatString="C2"
Increment="0.5"
Maximum="100"
Minimum="0"
ParsingNumberStyle="Any"
Watermark="Enter Text"
DefaultValue="10"
Value="25" />
</StackPanel>
</Grid>
</StackPanel>
</sample:DemoView>