123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- <UserControl x:Class="BlankApp1.Controls.MyDateTimePicker"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:BlankApp1.Controls"
- xmlns:convt="clr-namespace:BlankApp1.Controls.Convert"
- mc:Ignorable="d"
- Height="25" Width="145" Margin="2">
- <UserControl.Resources>
- <convt:InverseBooleanConverter x:Key="inverseBoolConvert"/>
- </UserControl.Resources>
- <Grid x:Name="GridMain">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="25"/>
- </Grid.ColumnDefinitions>
- <Border x:Name="BorderMain" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="Gray" Margin="0"/>
- <TextBox x:Name="TextDateTime" Tag="请选择时间">
- <TextBox.Style>
- <Style TargetType="TextBox">
- <Setter Property="Margin" Value="3"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="TextBox">
- <TextBlock Margin="2"
- VerticalAlignment="Center"
- FontSize="11"
- Text="{TemplateBinding TextBox.Text}"
- />
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="Text" Value=""/>
- </MultiTrigger.Conditions>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate>
- <Border BorderThickness="0" Margin="0" Padding="5,2,5,2">
- <TextBlock x:Name="MainTextBlock"
- Text="{TemplateBinding TextBox.Tag}"
- Width="{TemplateBinding TextBox.ActualWidth}"
- Foreground="Gray"
- FontSize="11"
- VerticalAlignment="Center"
- HorizontalAlignment="Left"/>
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </MultiTrigger>
- </Style.Triggers>
- </Style>
- </TextBox.Style>
- </TextBox>
- <ToggleButton x:Name="BtnPop" Grid.Column="1" ClickMode="Release" IsThreeState="False" IsEnabled="{Binding Path=IsOpen, ElementName=PopDateTime,Converter={StaticResource inverseBoolConvert}}">
- <ToggleButton.Template>
- <ControlTemplate>
- <Grid Background="Transparent" x:Name="GridIco">
- <TextBlock x:Name="TextIco" FontSize="15" Text="🕛" VerticalAlignment="Center" Foreground="Black"/>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="GridIco" Property="Background" Value="#008CD7"></Setter>
- <Setter TargetName="TextIco" Property="Foreground" Value="white"></Setter>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </ToggleButton.Template>
- </ToggleButton>
- <Popup x:Name="PopDateTime" PopupAnimation="Slide" AllowsTransparency="True" Placement="Bottom" StaysOpen="False" IsOpen="{Binding ElementName=BtnPop,Path=IsChecked,Mode=TwoWay}">
- <Grid Background="White">
- <Grid.RowDefinitions>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- </Grid.RowDefinitions>
- <Calendar x:Name="MyCalendar" Grid.Row="0" BorderThickness="0" SelectionMode="SingleDate" PreviewMouseUp="MyCalendar_PreviewMouseUp"/>
- <Grid Grid.Row="1" HorizontalAlignment="Center" Margin="6">
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition Width="22"/>
- <ColumnDefinition/>
- <ColumnDefinition Width="22"/>
- <ColumnDefinition/>
- <ColumnDefinition Width="22"/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Border Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" BorderThickness="1" BorderBrush="Transparent"/>
- <TextBlock Grid.Column="0" Text="时间:" Margin="5,2,5,2" VerticalAlignment="Center"/>
- <Button x:Name="Btnhh" Grid.Column="1" Content="00" Background="Transparent" BorderThickness="0" VerticalAlignment="Center" Click="Btnhh_Click"/>
- <TextBlock Grid.Column="2" Text=":" Margin="1,0,1,0" VerticalAlignment="Center"/>
- <Button x:Name="Btnmm" Grid.Column="3" Content="00" Background="Transparent" BorderThickness="0" VerticalAlignment="Center" Click="Btnmm_Click"/>
- <TextBlock Grid.Column="4" Text=":" Margin="1,0,1,0" VerticalAlignment="Center"/>
- <Button x:Name="Btnss" Grid.Column="5" Content="00" Background="Transparent" BorderThickness="0" VerticalAlignment="Center" Click="Btnss_Click"/>
- <Popup x:Name="Pop24" PopupAnimation="Slide" AllowsTransparency="True" PlacementTarget="{Binding ElementName=Btnhh}" Placement="Bottom" StaysOpen="False" IsOpen="False">
- <Grid>
- <!--四行六列,共24个-->
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- </Grid.RowDefinitions>
- <Grid.Resources>
- <Style TargetType="Button">
- <!--<Setter Property="Background" Value="#008CD7"/>-->
- <Setter Property="Background" Value="#eee"/>
- <Setter Property="BorderThickness" Value="0"/>
- <Setter Property="Height" Value="25"/>
- <Setter Property="Width" Value="25"/>
- <Setter Property="Margin" Value="1"/>
- <EventSetter Event="Click" Handler="Button_Click"/>
- </Style>
- </Grid.Resources>
- <Border Background="White" Grid.ColumnSpan="6" Grid.RowSpan="4"/>
- <Button Content="00" Grid.Row="0" Grid.Column="0"/>
- <Button Content="01" Grid.Row="0" Grid.Column="1"/>
- <Button Content="02" Grid.Row="0" Grid.Column="2"/>
- <Button Content="03" Grid.Row="0" Grid.Column="3"/>
- <Button Content="04" Grid.Row="0" Grid.Column="4"/>
- <Button Content="05" Grid.Row="0" Grid.Column="5"/>
- <Button Content="06" Grid.Row="1" Grid.Column="0"/>
- <Button Content="07" Grid.Row="1" Grid.Column="1"/>
- <Button Content="08" Grid.Row="1" Grid.Column="2"/>
- <Button Content="09" Grid.Row="1" Grid.Column="3"/>
- <Button Content="10" Grid.Row="1" Grid.Column="4"/>
- <Button Content="11" Grid.Row="1" Grid.Column="5"/>
- <Button Content="12" Grid.Row="2" Grid.Column="0"/>
- <Button Content="13" Grid.Row="2" Grid.Column="1"/>
- <Button Content="14" Grid.Row="2" Grid.Column="2"/>
- <Button Content="15" Grid.Row="2" Grid.Column="3"/>
- <Button Content="16" Grid.Row="2" Grid.Column="4"/>
- <Button Content="17" Grid.Row="2" Grid.Column="5"/>
- <Button Content="18" Grid.Row="3" Grid.Column="0"/>
- <Button Content="19" Grid.Row="3" Grid.Column="1"/>
- <Button Content="20" Grid.Row="3" Grid.Column="2"/>
- <Button Content="21" Grid.Row="3" Grid.Column="3"/>
- <Button Content="22" Grid.Row="3" Grid.Column="4"/>
- <Button Content="23" Grid.Row="3" Grid.Column="5"/>
- </Grid>
- </Popup>
- <Popup x:Name="Pop60" PopupAnimation="Slide" AllowsTransparency="True" PlacementTarget="{Binding ElementName=Btnhh}" Placement="Bottom" StaysOpen="False" IsOpen="False">
- <Grid>
- <!--十行六列,共60个-->
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- <RowDefinition/>
- </Grid.RowDefinitions>
- <Grid.Resources>
- <Style TargetType="Button">
- <!--<Setter Property="Background" Value="#008CD7"/>-->
- <Setter Property="Background" Value="#eee"/>
- <Setter Property="BorderThickness" Value="0"/>
- <Setter Property="Height" Value="25"/>
- <Setter Property="Width" Value="25"/>
- <Setter Property="Margin" Value="1"/>
- <EventSetter Event="Click" Handler="Button_Click_1"/>
- </Style>
- </Grid.Resources>
- <Border Background="White" Grid.ColumnSpan="6" Grid.RowSpan="10"/>
- <Button Content="00" Grid.Row="0" Grid.Column="0"/>
- <Button Content="01" Grid.Row="0" Grid.Column="1"/>
- <Button Content="02" Grid.Row="0" Grid.Column="2"/>
- <Button Content="03" Grid.Row="0" Grid.Column="3"/>
- <Button Content="04" Grid.Row="0" Grid.Column="4"/>
- <Button Content="05" Grid.Row="0" Grid.Column="5"/>
- <Button Content="06" Grid.Row="1" Grid.Column="0"/>
- <Button Content="07" Grid.Row="1" Grid.Column="1"/>
- <Button Content="08" Grid.Row="1" Grid.Column="2"/>
- <Button Content="09" Grid.Row="1" Grid.Column="3"/>
- <Button Content="10" Grid.Row="1" Grid.Column="4"/>
- <Button Content="11" Grid.Row="1" Grid.Column="5"/>
- <Button Content="12" Grid.Row="2" Grid.Column="0"/>
- <Button Content="13" Grid.Row="2" Grid.Column="1"/>
- <Button Content="14" Grid.Row="2" Grid.Column="2"/>
- <Button Content="15" Grid.Row="2" Grid.Column="3"/>
- <Button Content="16" Grid.Row="2" Grid.Column="4"/>
- <Button Content="17" Grid.Row="2" Grid.Column="5"/>
- <Button Content="18" Grid.Row="3" Grid.Column="0"/>
- <Button Content="19" Grid.Row="3" Grid.Column="1"/>
- <Button Content="20" Grid.Row="3" Grid.Column="2"/>
- <Button Content="21" Grid.Row="3" Grid.Column="3"/>
- <Button Content="22" Grid.Row="3" Grid.Column="4"/>
- <Button Content="23" Grid.Row="3" Grid.Column="5"/>
- <Button Content="24" Grid.Row="4" Grid.Column="0"/>
- <Button Content="25" Grid.Row="4" Grid.Column="1"/>
- <Button Content="26" Grid.Row="4" Grid.Column="2"/>
- <Button Content="27" Grid.Row="4" Grid.Column="3"/>
- <Button Content="28" Grid.Row="4" Grid.Column="4"/>
- <Button Content="29" Grid.Row="4" Grid.Column="5"/>
- <Button Content="30" Grid.Row="5" Grid.Column="0"/>
- <Button Content="31" Grid.Row="5" Grid.Column="1"/>
- <Button Content="32" Grid.Row="5" Grid.Column="2"/>
- <Button Content="33" Grid.Row="5" Grid.Column="3"/>
- <Button Content="34" Grid.Row="5" Grid.Column="4"/>
- <Button Content="35" Grid.Row="5" Grid.Column="5"/>
- <Button Content="36" Grid.Row="6" Grid.Column="0"/>
- <Button Content="37" Grid.Row="6" Grid.Column="1"/>
- <Button Content="38" Grid.Row="6" Grid.Column="2"/>
- <Button Content="39" Grid.Row="6" Grid.Column="3"/>
- <Button Content="40" Grid.Row="6" Grid.Column="4"/>
- <Button Content="41" Grid.Row="6" Grid.Column="5"/>
- <Button Content="42" Grid.Row="7" Grid.Column="0"/>
- <Button Content="43" Grid.Row="7" Grid.Column="1"/>
- <Button Content="44" Grid.Row="7" Grid.Column="2"/>
- <Button Content="45" Grid.Row="7" Grid.Column="3"/>
- <Button Content="46" Grid.Row="7" Grid.Column="4"/>
- <Button Content="47" Grid.Row="7" Grid.Column="5"/>
- <Button Content="48" Grid.Row="8" Grid.Column="0"/>
- <Button Content="49" Grid.Row="8" Grid.Column="1"/>
- <Button Content="50" Grid.Row="8" Grid.Column="2"/>
- <Button Content="51" Grid.Row="8" Grid.Column="3"/>
- <Button Content="52" Grid.Row="8" Grid.Column="4"/>
- <Button Content="53" Grid.Row="8" Grid.Column="5"/>
- <Button Content="54" Grid.Row="9" Grid.Column="0"/>
- <Button Content="55" Grid.Row="9" Grid.Column="1"/>
- <Button Content="56" Grid.Row="9" Grid.Column="2"/>
- <Button Content="57" Grid.Row="9" Grid.Column="3"/>
- <Button Content="58" Grid.Row="9" Grid.Column="4"/>
- <Button Content="59" Grid.Row="9" Grid.Column="5"/>
- </Grid>
- </Popup>
- </Grid>
- <Grid Grid.Row="2" Margin="1">
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Button x:Name="BtnNow" Grid.Column="0" Content="当前" Background="#6BE6C1" BorderBrush="#6BE6C1" Click="BtnNow_Click"/>
- <Button x:Name="BtnSave" Grid.Column="1" Content="确定" Click="BtnSave_Click" />
- </Grid>
- </Grid>
- </Popup>
- </Grid>
- </UserControl>
|