123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <UserControl x:Class="Compdfkit_Tools.Common.DropDownNumberBoxControl"
- 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:cpdfcommon="clr-namespace:Compdfkit_Tools.Common"
- mc:Ignorable="d"
- d:DesignHeight="30" d:DesignWidth="100">
- <UserControl.Resources>
- <cpdfcommon:BoolToVisibleConverter x:Key="BoolToVisibleConverter"></cpdfcommon:BoolToVisibleConverter>
- <cpdfcommon:BoolToCollapsedConverter x:Key="BoolToCollapsedConverter"></cpdfcommon:BoolToCollapsedConverter>
- <SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
- <SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
- <SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
- <Style x:Key="LimitedNumberBoxWithUnit" TargetType="{x:Type TextBox}">
- <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
- <Setter Property="BorderBrush" Value="Transparent"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
- <Setter Property="HorizontalContentAlignment" Value="Left"/>
- <Setter Property="VerticalContentAlignment" Value="Center"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="AllowDrop" Value="true"/>
- <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
- <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type TextBox}">
- <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="20"/>
- </Grid.ColumnDefinitions>
- <ScrollViewer Grid.Column="0" x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Margin="5,0,0,0"/>
- <TextBlock Grid.Column="1" Text="{Binding Unit, RelativeSource={RelativeSource AncestorType=UserControl}}" HorizontalAlignment="Right" VerticalAlignment="Center"/>
- </Grid>
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="TransparentToggleButton" TargetType="{x:Type ToggleButton}">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="BorderBrush" Value="Transparent"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ToggleButton}">
- <Border x:Name="border"
- Background="{TemplateBinding Background}"
- BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="{TemplateBinding BorderThickness}"
- Padding="{TemplateBinding Padding}">
- <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
- RecognizesAccessKey="True"/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsChecked" Value="True">
- <Setter TargetName="border" Property="Opacity" Value="0"/>
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="border" Property="Opacity" Value="0"/>
- </Trigger>
- <Trigger Property="IsPressed" Value="True">
- <Setter TargetName="border" Property="Opacity" Value="0"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="PresetComboBox" TargetType="{x:Type ComboBox}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ComboBox}">
- <Border x:Name="border" BorderBrush="{StaticResource TextBox.Static.Border}" BorderThickness="1" Background="#FFFFFF">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition></ColumnDefinition>
- <ColumnDefinition Width="15"></ColumnDefinition>
- </Grid.ColumnDefinitions>
- <Grid Grid.Column="1">
- <Path Fill="#CDCDCD" Stroke="#CDCDCD" Grid.Column="1" Height="4.8" Width="7.38" Stretch="Fill" Visibility="{Binding Path=IsDropDownOpen,Converter={StaticResource BoolToCollapsedConverter},RelativeSource={RelativeSource TemplatedParent}}">
- <Path.Data>
- <PathGeometry Figures="M917.284001 297.722752c-5.406127-5.437849-13.06762-8.396227-21.479197-8.396227-9.611915 0-18.953677 3.844561-25.713638 10.543124L511.980046 659.992589 153.873018 299.91672c-6.729262-6.745634-16.072047-10.619872-25.654286-10.619872-8.470929 0-16.131399 2.989077-21.598924 8.457626-12.301164 12.435217-11.32493 33.69031 2.192945 47.312562l376.764969 378.821815c6.758937 6.788613 15.860223 10.723226 25.052582 10.8143l3.425006 0c8.981559-0.301875 17.814738-4.205788 24.423249-10.8143l376.733247-378.852514C928.728658 331.382363 929.690566 310.113967 917.284001 297.722752" ></PathGeometry>
- </Path.Data>
- </Path>
- <Path Fill="#CDCDCD" Stroke="#CDCDCD" Grid.Column="1" Height="4.8" Width="7.38" Stretch="Fill" Visibility="{Binding Path=IsDropDownOpen,Converter={StaticResource BoolToVisibleConverter},RelativeSource={RelativeSource TemplatedParent}}">
- <Path.Data>
- <PathGeometry Figures="M511.99386 361.932146L130.652665 743.283574c-14.944364 14.95869-39.187511 14.95869-54.14313 0-14.95869-14.95562-14.95869-39.187511 0-54.143131l408.411736-408.426063c14.95869-14.95562 39.187511-14.95562 54.144155 0l408.426063 408.426063c7.478322 7.478322 11.217483 17.275455 11.217482 27.072589 0 9.79611-3.739161 19.59222-11.217482 27.070542-14.95562 14.95869-39.187511 14.95869-54.143131 0L511.99386 361.932146z" ></PathGeometry>
- </Path.Data>
- </Path>
- </Grid>
- <Grid Grid.Column="0" Grid.ColumnSpan="2">
- <ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
- ClickMode="Press" Style="{StaticResource TransparentToggleButton}"></ToggleButton>
- <Popup Name="popup"
- IsOpen="{TemplateBinding IsDropDownOpen}"
- Placement="Bottom" AllowsTransparency="True" PopupAnimation="Fade" VerticalOffset="1">
- <Border MinWidth="{TemplateBinding ActualWidth}"
- MaxHeight="{TemplateBinding MaxDropDownHeight}">
- <ScrollViewer MaxHeight="{TemplateBinding MaxDropDownHeight}"
- HorizontalScrollBarVisibility="Auto"
- VerticalScrollBarVisibility="Auto">
- <Border BorderBrush ="LightGray" BorderThickness="1">
- <StackPanel Background="#FFFFFF" MinHeight="20"
- IsItemsHost="True"/>
- </Border>
- </ScrollViewer>
- </Border>
- </Popup>
- </Grid>
- </Grid>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="true">
- <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </UserControl.Resources>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="1*"></ColumnDefinition>
- <ColumnDefinition Width="20"></ColumnDefinition>
- </Grid.ColumnDefinitions>
- <ComboBox Grid.ColumnSpan="2" x:Name="ComboBox" Background="#FFFFFF" Style="{StaticResource PresetComboBox}" SelectionChanged="ComboBox_SelectionChanged" ></ComboBox>
- <TextBox x:Name="TextBox" Text="{Binding Text, RelativeSource={RelativeSource AncestorType=UserControl}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource LimitedNumberBoxWithUnit}" HorizontalContentAlignment="Center" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="TextBox_PreviewTextInput" PreviewKeyDown="TextBox_PreviewKeyDown" TextChanged="TextBox_TextChanged" >
- </TextBox>
- </Grid>
- </UserControl>
|