IpTextBox.xaml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:ZUI="clr-namespace:CustomUI">
  4. <Color x:Key="Color.Light.Border.Normal">#ABADB3</Color>
  5. <Color x:Key="Color.Light.Border.MouseOver">#5CADFF</Color>
  6. <Color x:Key="Color.Disabled.Background">#F3F3F3</Color>
  7. <Style x:Key="IpBoxStyle" TargetType="TextBox">
  8. <Setter Property="Background" Value="Transparent" />
  9. <Setter Property="VerticalContentAlignment" Value="Center" />
  10. <Setter Property="HorizontalContentAlignment" Value="Center" />
  11. <Setter Property="BorderThickness" Value="0" />
  12. </Style>
  13. <Style TargetType="{x:Type ZUI:IpTextBox}">
  14. <Setter Property="BorderBrush" Value="#ABADB3" />
  15. <Setter Property="BorderThickness" Value="1" />
  16. <Setter Property="VerticalContentAlignment" Value="Center" />
  17. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  18. <Setter Property="SnapsToDevicePixels" Value="True" />
  19. <Setter Property="UseLayoutRounding" Value="True" />
  20. <Setter Property="Padding" Value="1" />
  21. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  22. <Setter Property="Template">
  23. <Setter.Value>
  24. <ControlTemplate TargetType="{x:Type ZUI:IpTextBox}">
  25. <Border x:Name="Root" BorderBrush="{TemplateBinding BorderBrush}"
  26. BorderThickness="{TemplateBinding BorderThickness}"
  27. Background="{TemplateBinding Background}"
  28. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  29. UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
  30. CornerRadius="0">
  31. <Grid>
  32. <Grid.ColumnDefinitions>
  33. <ColumnDefinition Width="*" />
  34. <ColumnDefinition Width="auto" />
  35. <ColumnDefinition Width="*" />
  36. <ColumnDefinition Width="auto" />
  37. <ColumnDefinition Width="*" />
  38. <ColumnDefinition Width="auto" />
  39. <ColumnDefinition Width="*" />
  40. </Grid.ColumnDefinitions>
  41. <TextBox x:Name="PART_BOX1" Style="{StaticResource IpBoxStyle}"
  42. FontSize="{TemplateBinding FontSize}"
  43. FontFamily="{TemplateBinding FontFamily}"/>
  44. <TextBlock Grid.Column="1" Text="." VerticalAlignment="Bottom" Margin="0,0,0,5" />
  45. <TextBox x:Name="PART_BOX2" Grid.Column="2" Style="{StaticResource IpBoxStyle}"
  46. FontSize="{TemplateBinding FontSize}"
  47. FontFamily="{TemplateBinding FontFamily}"/>
  48. <TextBlock Grid.Column="3" Text="." VerticalAlignment="Bottom" Margin="0,0,0,5" />
  49. <TextBox x:Name="PART_BOX3" Grid.Column="4" Style="{StaticResource IpBoxStyle}"
  50. FontSize="{TemplateBinding FontSize}"
  51. FontFamily="{TemplateBinding FontFamily}"/>
  52. <TextBlock Grid.Column="5" Text="." VerticalAlignment="Bottom" Margin="0,0,0,5" />
  53. <TextBox x:Name="PART_BOX4" Grid.Column="6" Style="{StaticResource IpBoxStyle}"
  54. FontSize="{TemplateBinding FontSize}"
  55. FontFamily="{TemplateBinding FontFamily}"/>
  56. <ZUI:Poptip AllowsTransparency="True" StaysOpen="False" Background="Red"
  57. BorderThickness="0"
  58. IsOpen="{Binding IsHasError, Mode=OneWay, RelativeSource={RelativeSource AncestorType=ZUI:IpTextBox}}"
  59. PlacementEx="TopLeft" PlacementTarget="{Binding ElementName=Root}">
  60. <TextBlock Text="{TemplateBinding ErrorContent}" Margin="3" Foreground="White" />
  61. </ZUI:Poptip>
  62. </Grid>
  63. </Border>
  64. <ControlTemplate.Triggers>
  65. <Trigger Property="IsKeyboardFocused" Value="True">
  66. <Setter Property="BorderBrush" Value="#0000FF" />
  67. </Trigger>
  68. <Trigger Property="IsHasError" Value="True">
  69. <Setter Property="BorderBrush" Value="Red" />
  70. </Trigger>
  71. <MultiTrigger>
  72. <MultiTrigger.Conditions>
  73. <Condition Property="IsKeyboardFocused" Value="True" />
  74. <Condition Property="IsMouseOver" Value="False" />
  75. </MultiTrigger.Conditions>
  76. <Setter Property="BorderBrush" Value="#0000FF" />
  77. </MultiTrigger>
  78. </ControlTemplate.Triggers>
  79. </ControlTemplate>
  80. </Setter.Value>
  81. </Setter>
  82. </Style>
  83. </ResourceDictionary>