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.
476 lines
22 KiB
476 lines
22 KiB
<!--*************************************************************************************
|
|
|
|
Toolkit for WPF
|
|
|
|
Copyright (C) 2007-2025 Xceed Software Inc.
|
|
|
|
This program is provided to you under the terms of the XCEED SOFTWARE, INC.
|
|
COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at
|
|
https://github.com/xceedsoftware/wpftoolkit/blob/master/license.md
|
|
|
|
For more features, controls, and fast professional support,
|
|
pick up the Plus Edition at https://xceed.com/xceed-toolkit-plus-for-wpf/
|
|
|
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
|
|
|
***********************************************************************************-->
|
|
|
|
<local:DemoView x:Class="Xceed.Wpf.Toolkit.LiveExplorer.Samples.DateTime.Views.DateTimeView"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
|
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit.LiveExplorer"
|
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
|
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.LiveExplorer.Samples.DateTime.Converters"
|
|
Title="DateTime">
|
|
<local:DemoView.Description>
|
|
<Paragraph FontSize="14"
|
|
FontFamily="Segoe">
|
|
The DateTimePicker and TimePicker controls let you select the date and the time in several ways. The TimePicker is used in the DateTimePicker.
|
|
</Paragraph>
|
|
</local:DemoView.Description>
|
|
|
|
<local:DemoView.Resources>
|
|
<conv:DateTimeToTimeSpanConverter x:Key="dateTimeToTimeSpanConverter" />
|
|
<conv:CustomFormatToBoolConverter x:Key="CustomFormatToBoolConverter" />
|
|
|
|
<ObjectDataProvider x:Key="enumDateFormatData"
|
|
MethodName="GetValues"
|
|
ObjectType="{x:Type sys:Enum}">
|
|
<ObjectDataProvider.MethodParameters>
|
|
<x:Type TypeName="xctk:DateTimeFormat" />
|
|
</ObjectDataProvider.MethodParameters>
|
|
</ObjectDataProvider>
|
|
<ObjectDataProvider x:Key="enumVisibility"
|
|
MethodName="GetValues"
|
|
ObjectType="{x:Type sys:Enum}">
|
|
<ObjectDataProvider.MethodParameters>
|
|
<x:Type TypeName="Visibility" />
|
|
</ObjectDataProvider.MethodParameters>
|
|
</ObjectDataProvider>
|
|
<ObjectDataProvider x:Key="enumKind"
|
|
MethodName="GetValues"
|
|
ObjectType="{x:Type sys:Enum}">
|
|
<ObjectDataProvider.MethodParameters>
|
|
<x:Type TypeName="sys:DateTimeKind" />
|
|
</ObjectDataProvider.MethodParameters>
|
|
</ObjectDataProvider>
|
|
<ObjectDataProvider x:Key="enumCalendarDisplayMode"
|
|
MethodName="GetValues"
|
|
ObjectType="{x:Type sys:Enum}">
|
|
<ObjectDataProvider.MethodParameters>
|
|
<x:Type TypeName="CalendarMode" />
|
|
</ObjectDataProvider.MethodParameters>
|
|
</ObjectDataProvider>
|
|
<ObjectDataProvider x:Key="enumDateTimePart"
|
|
MethodName="GetValues"
|
|
ObjectType="{x:Type sys:Enum}">
|
|
<ObjectDataProvider.MethodParameters>
|
|
<x:Type TypeName="xctk:DateTimePart" />
|
|
</ObjectDataProvider.MethodParameters>
|
|
</ObjectDataProvider>
|
|
</local:DemoView.Resources>
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<GroupBox Header="Features"
|
|
Grid.ColumnSpan="2"
|
|
HorizontalAlignment="Stretch">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<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" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<TextBlock Text="Format:"
|
|
Grid.Row="0"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<ComboBox x:Name="_format"
|
|
Grid.Row="0"
|
|
Grid.Column="1"
|
|
SelectedIndex="1"
|
|
ItemsSource="{Binding Source={StaticResource enumDateFormatData}}"
|
|
Width="185"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="FormatString:"
|
|
Grid.Row="1"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center"
|
|
IsEnabled="{Binding IsEnabled, ElementName=_formatString}"
|
|
Style="{StaticResource DisableGrayText}" />
|
|
<TextBox x:Name="_formatString"
|
|
Grid.Row="1"
|
|
Grid.Column="1"
|
|
Text="yy MMM dd"
|
|
Width="185"
|
|
IsEnabled="{Binding Source={x:Reference _format}, Path=SelectedItem, Converter={StaticResource CustomFormatToBoolConverter}}"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="Watermark:"
|
|
Grid.Row="2"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<TextBox x:Name="_watermark"
|
|
Grid.Row="2"
|
|
Grid.Column="1"
|
|
Text="Enter Text"
|
|
Width="185"
|
|
VerticalAlignment="Center"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="AutoCloseCalendar:"
|
|
Grid.Row="3"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<CheckBox x:Name="_autoCloseCalendar"
|
|
Grid.Row="3"
|
|
Grid.Column="1"
|
|
IsChecked="False"
|
|
VerticalAlignment="Center"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="AutoCloseCalendarOnTimeSelection:"
|
|
Grid.Row="4"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<CheckBox x:Name="_autoCloseCalendarOnTimeSelection"
|
|
Grid.Row="4"
|
|
Grid.Column="1"
|
|
IsChecked="False"
|
|
VerticalAlignment="Center"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="ClipValueToMinMax:"
|
|
Grid.Row="5"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<CheckBox x:Name="_clipValueToMinMax"
|
|
Grid.Row="5"
|
|
Grid.Column="1"
|
|
IsChecked="False"
|
|
VerticalAlignment="Center"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="CalendarDisplayMode:"
|
|
Grid.Row="6"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<ComboBox x:Name="_calendarDisplayMode"
|
|
Grid.Row="6"
|
|
Grid.Column="1"
|
|
SelectedIndex="0"
|
|
ItemsSource="{Binding Source={StaticResource enumCalendarDisplayMode}}"
|
|
Width="185"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="ShowDropDownButton:"
|
|
Grid.Row="7"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<CheckBox x:Name="_showDropDownButton"
|
|
Grid.Row="7"
|
|
Grid.Column="1"
|
|
IsChecked="True"
|
|
VerticalAlignment="Center"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="TimePickerVisibility:"
|
|
Grid.Row="8"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<ComboBox x:Name="_timePickerVisibility"
|
|
Grid.Row="8"
|
|
Grid.Column="1"
|
|
SelectedIndex="0"
|
|
ItemsSource="{Binding Source={StaticResource enumVisibility}}"
|
|
Width="185"
|
|
Margin="5,5,25,5" />
|
|
<TextBlock Text="TimePickerShowButtonSpinner:"
|
|
Grid.Row="9"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<CheckBox x:Name="_timePickerShowButtonSpinner"
|
|
Grid.Row="9"
|
|
Grid.Column="1"
|
|
IsChecked="True"
|
|
VerticalAlignment="Center"
|
|
Margin="5" />
|
|
<TextBlock Text="TodayButtonVisibility:"
|
|
Grid.Row="10"
|
|
Grid.Column="0"
|
|
VerticalAlignment="Center" />
|
|
<ComboBox x:Name="_todayButtonVisibility"
|
|
Grid.Row="10"
|
|
Grid.Column="1"
|
|
SelectedIndex="0"
|
|
ItemsSource="{Binding Source={StaticResource enumVisibility}}"
|
|
Width="185"
|
|
Margin="5,5,25,5" />
|
|
|
|
|
|
<TextBlock Text="TimeFormat:"
|
|
Grid.Row="0"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<ComboBox x:Name="_timeFormat"
|
|
Grid.Row="0"
|
|
Grid.Column="3"
|
|
SelectedIndex="7"
|
|
ItemsSource="{Binding Source={StaticResource enumDateFormatData}}"
|
|
Width="185"
|
|
Margin="5" />
|
|
<TextBlock Text="Time FormatString:"
|
|
Grid.Row="1"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center"
|
|
IsEnabled="{Binding IsEnabled, ElementName=_timeFormatString}"
|
|
Style="{StaticResource DisableGrayText}" />
|
|
<TextBox x:Name="_timeFormatString"
|
|
Grid.Row="1"
|
|
Grid.Column="3"
|
|
Text="H:mm"
|
|
Width="185"
|
|
IsEnabled="{Binding Source={x:Reference _timeFormat}, Path=SelectedItem, Converter={StaticResource CustomFormatToBoolConverter}}"
|
|
Margin="5" />
|
|
<TextBlock Text="TimeWatermark:"
|
|
Grid.Row="2"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<TextBox x:Name="_timeWatermark"
|
|
Grid.Row="2"
|
|
Grid.Column="3"
|
|
Text="Enter Text"
|
|
Width="185"
|
|
VerticalAlignment="Center"
|
|
Margin="5" />
|
|
<TextBlock Text="Minimum:"
|
|
Grid.Row="3"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<xctk:DateTimeUpDown x:Name="_minimum"
|
|
Grid.Row="3"
|
|
Grid.Column="3"
|
|
Format="Custom"
|
|
FormatString="yyyy/MM/dd HH:mm"
|
|
Value="2016/01/01T12:00"
|
|
Width="185"
|
|
VerticalAlignment="Center"
|
|
Margin="5" />
|
|
<TextBlock Text="Maximum:"
|
|
Grid.Row="4"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<xctk:DateTimeUpDown x:Name="_maximum"
|
|
Grid.Row="4"
|
|
Grid.Column="3"
|
|
Format="Custom"
|
|
FormatString="yyyy/MM/dd HH:mm"
|
|
Value="2030/12/31T12:00"
|
|
Width="185"
|
|
VerticalAlignment="Center"
|
|
Margin="5" />
|
|
<TextBlock Text="CurrentDateTimePart:"
|
|
Grid.Row="5"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<ComboBox x:Name="_currentDateTimePart"
|
|
Grid.Row="5"
|
|
Grid.Column="3"
|
|
SelectedIndex="0"
|
|
ItemsSource="{Binding Source={StaticResource enumDateTimePart}}"
|
|
Width="185"
|
|
Margin="5"
|
|
ToolTip="Must match a DateTimePart of the DateTimePicker Format." />
|
|
<TextBlock Text="Auto Clip time Parts:"
|
|
Grid.Row="6"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<CheckBox x:Name="_autoClipTimeParts"
|
|
Grid.Row="6"
|
|
Grid.Column="3"
|
|
IsChecked="False"
|
|
VerticalAlignment="Center"
|
|
Margin="5" />
|
|
<TextBlock Text="Kind:"
|
|
Grid.Row="7"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<ComboBox x:Name="_kind"
|
|
Grid.Row="7"
|
|
Grid.Column="3"
|
|
SelectedIndex="2"
|
|
ItemsSource="{Binding Source={StaticResource enumKind}}"
|
|
Width="185"
|
|
Margin="5" />
|
|
<TextBlock Text="CalendarWidth:"
|
|
Grid.Row="8"
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center" />
|
|
<xctk:DoubleUpDown x:Name="_calendarWidth"
|
|
Grid.Row="8"
|
|
Grid.Column="3"
|
|
Value="178"
|
|
Minimum="100"
|
|
Maximum="500"
|
|
Width="185"
|
|
Margin="5" />
|
|
</Grid>
|
|
</GroupBox>
|
|
|
|
<StackPanel Grid.Row="1"
|
|
Grid.Column="0"
|
|
HorizontalAlignment="Left">
|
|
<TextBlock Text="DateTimePicker Usage: "
|
|
Margin="0,10,0,0"
|
|
Style="{StaticResource Header}" />
|
|
<!--##EXCLUDE_OPEN_SOURCE-->
|
|
<xctk:DateTimePicker x:Name="_datetimePicker"
|
|
Width="300"
|
|
VerticalAlignment="Top"
|
|
IsReadOnly="False"
|
|
Format="{Binding Source={x:Reference _format}, Path=SelectedItem}"
|
|
FormatString="{Binding Text, ElementName=_formatString}"
|
|
Watermark="{Binding Source={x:Reference _watermark}, Path=Text}"
|
|
TimeFormat="{Binding Source={x:Reference _timeFormat}, Path=SelectedItem}"
|
|
TimeFormatString="{Binding Text, ElementName=_timeFormatString}"
|
|
TimeWatermark="{Binding Source={x:Reference _timeWatermark}, Path=Text}"
|
|
AutoCloseCalendar="{Binding IsChecked, ElementName=_autoCloseCalendar}"
|
|
AutoCloseCalendarOnTimeSelection="{Binding IsChecked, ElementName=_autoCloseCalendarOnTimeSelection}"
|
|
ClipValueToMinMax="{Binding IsChecked, ElementName=_clipValueToMinMax}"
|
|
TimePickerVisibility="{Binding Source={x:Reference _timePickerVisibility}, Path=SelectedItem}"
|
|
TimePickerShowButtonSpinner="{Binding IsChecked, ElementName=_timePickerShowButtonSpinner}"
|
|
TodayButtonVisibility="{Binding Source={x:Reference _todayButtonVisibility}, Path=SelectedItem}"
|
|
Minimum="{Binding Value, ElementName=_minimum}"
|
|
Maximum="{Binding Value, ElementName=_maximum}"
|
|
Kind="{Binding SelectedItem, ElementName=_kind}"
|
|
CalendarDisplayMode="{Binding SelectedItem, ElementName=_calendarDisplayMode}"
|
|
CalendarWidth="{Binding Value, ElementName=_calendarWidth}"
|
|
ShowDropDownButton="{Binding IsChecked, ElementName=_showDropDownButton}"
|
|
CurrentDateTimePart="{Binding SelectedItem, ElementName=_currentDateTimePart, Mode=TwoWay}"
|
|
AutoClipTimeParts="{Binding IsChecked, ElementName=_autoClipTimeParts}" />
|
|
<!--##END-->
|
|
<!--##INCLUDE_OPEN_SOURCE
|
|
<xctk:DateTimePicker x:Name="_datetimePicker"
|
|
Width="300"
|
|
VerticalAlignment="Top"
|
|
IsReadOnly="False"
|
|
Format="{Binding Source={x:Reference _format}, Path=SelectedItem}"
|
|
FormatString="{Binding Text, ElementName=_formatString}"
|
|
Watermark="{Binding Source={x:Reference _watermark}, Path=Text}"
|
|
TimeFormat="{Binding Source={x:Reference _timeFormat}, Path=SelectedItem}"
|
|
TimeFormatString="{Binding Text, ElementName=_timeFormatString}"
|
|
TimeWatermark="{Binding Source={x:Reference _timeWatermark}, Path=Text}"
|
|
AutoCloseCalendar="{Binding IsChecked, ElementName=_autoCloseCalendar}"
|
|
ClipValueToMinMax="{Binding IsChecked, ElementName=_clipValueToMinMax}"
|
|
TimePickerVisibility="{Binding Source={x:Reference _timePickerVisibility}, Path=SelectedItem}"
|
|
TimePickerShowButtonSpinner="{Binding IsChecked, ElementName=_timePickerShowButtonSpinner}"
|
|
Minimum="{Binding Value, ElementName=_minimum}"
|
|
Maximum="{Binding Value, ElementName=_maximum}"
|
|
Kind="{Binding SelectedItem, ElementName=_kind}"
|
|
CalendarDisplayMode="{Binding SelectedItem, ElementName=_calendarDisplayMode}"
|
|
CalendarWidth="{Binding Value, ElementName=_calendarWidth}"
|
|
ShowDropDownButton="{Binding IsChecked, ElementName=_showDropDownButton}"
|
|
CurrentDateTimePart="{Binding SelectedItem, ElementName=_currentDateTimePart, Mode=TwoWay}"
|
|
AutoClipTimeParts="{Binding IsChecked, ElementName=_autoClipTimeParts}" />
|
|
##END-->
|
|
</StackPanel>
|
|
|
|
<StackPanel Grid.Row="1"
|
|
Grid.Column="1"
|
|
HorizontalAlignment="Stretch">
|
|
<GroupBox Header="TimePicker Features"
|
|
Margin="0,15,0,0">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="Auto" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<TextBlock Text="StartTime:"
|
|
VerticalAlignment="Center" />
|
|
<xctk:DateTimeUpDown x:Name="_startTime"
|
|
Grid.Column="1"
|
|
Format="ShortTime"
|
|
Value="9:00"
|
|
Width="100"
|
|
Margin="5" />
|
|
<TextBlock Text="EndTime:"
|
|
Grid.Row="1"
|
|
VerticalAlignment="Center" />
|
|
<xctk:DateTimeUpDown x:Name="_endTime"
|
|
Grid.Row="1"
|
|
Grid.Column="1"
|
|
Format="ShortTime"
|
|
Value="17:00"
|
|
Width="100"
|
|
Margin="5" />
|
|
<TextBlock Text="TimeInterval:"
|
|
Grid.Row="2"
|
|
VerticalAlignment="Center" />
|
|
<xctk:DateTimeUpDown x:Name="_timeInterval"
|
|
Grid.Row="2"
|
|
Grid.Column="1"
|
|
Format="Custom"
|
|
FormatString="H:mm"
|
|
Value="0:30"
|
|
Width="100"
|
|
Margin="5" />
|
|
<TextBlock Grid.Row="3"
|
|
Text="MaxDropDownHeight:"
|
|
VerticalAlignment="Center" />
|
|
<xctk:DoubleUpDown x:Name="_maxDropDownHeight"
|
|
Grid.Row="3"
|
|
Grid.Column="1"
|
|
Width="100"
|
|
Value="130"
|
|
DefaultValue="130"
|
|
AllowInputSpecialValues="PositiveInfinity"
|
|
Minimum="0" />
|
|
</Grid>
|
|
</GroupBox>
|
|
|
|
<StackPanel>
|
|
<TextBlock Text="TimePicker Usage: "
|
|
Style="{StaticResource Header}" />
|
|
<xctk:TimePicker x:Name="_timePicker"
|
|
VerticalAlignment="Top"
|
|
Format="{Binding Source={x:Reference _timeFormat}, Path=SelectedItem}"
|
|
FormatString="{Binding Text, ElementName=_timeFormatString}"
|
|
Watermark="{Binding Source={x:Reference _timeWatermark}, Path=Text}"
|
|
StartTime="{Binding Source={x:Reference _startTime}, Path=Value, Converter={StaticResource dateTimeToTimeSpanConverter}}"
|
|
EndTime="{Binding Source={x:Reference _endTime}, Path=Value, Converter={StaticResource dateTimeToTimeSpanConverter}}"
|
|
TimeInterval="{Binding Source={x:Reference _timeInterval}, Path=Value, Converter={StaticResource dateTimeToTimeSpanConverter}}"
|
|
ClipValueToMinMax="{Binding IsChecked, ElementName=_clipValueToMinMax}"
|
|
Minimum="{Binding Value, ElementName=_minimum}"
|
|
Maximum="{Binding Value, ElementName=_maximum}"
|
|
MaxDropDownHeight="{Binding Value, ElementName=_maxDropDownHeight}"
|
|
ShowDropDownButton="{Binding IsChecked, ElementName=_showDropDownButton}"
|
|
AutoClipTimeParts="{Binding IsChecked, ElementName=_autoClipTimeParts}" />
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Grid>
|
|
</local:DemoView>
|
|
|