NumbericTextBox.xaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. <PathGeometry x:Key="Error" Figures="M512 83.577816c-237.289317 0-429.650196 192.360879-429.650196 429.650196s192.360879 429.650196 429.650196 429.650196S941.650196 750.517329 941.650196 513.228012 749.289317 83.577816 512 83.577816z m34.016332 644.469294H477.984668v-68.031665h68.031664v68.031665z m0-89.476874H477.984668l-17.734173-340.160322h103.50101l-17.735173 340.160322z" />
  8. <Style TargetType="{x:Type ZUI:NumbericTextBox}">
  9. <Setter Property="Background" Value="Transparent" />
  10. <Setter Property="BorderBrush" Value="#ABADB3" />
  11. <Setter Property="BorderThickness" Value="1" />
  12. <Setter Property="HorizontalAlignment" Value="Stretch" />
  13. <Setter Property="VerticalAlignment" Value="Stretch" />
  14. <Setter Property="VerticalContentAlignment" Value="Center" />
  15. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  16. <Setter Property="SnapsToDevicePixels" Value="True" />
  17. <Setter Property="UseLayoutRounding" Value="True" />
  18. <Setter Property="Padding" Value="2,0" />
  19. <Setter Property="Height" Value="25" />
  20. <Setter Property="ErrorBackground" Value="Red" />
  21. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  22. <Setter Property="ErrorContentTemplate">
  23. <Setter.Value>
  24. <DataTemplate>
  25. <TextBlock Text="{Binding .}" Foreground="White" Margin="3" />
  26. </DataTemplate>
  27. </Setter.Value>
  28. </Setter>
  29. <Setter Property="Template">
  30. <Setter.Value>
  31. <ControlTemplate TargetType="{x:Type ZUI:NumbericTextBox}">
  32. <Border x:Name="Border"
  33. Background="{TemplateBinding Background}"
  34. BorderBrush="{TemplateBinding BorderBrush}"
  35. BorderThickness="{TemplateBinding BorderThickness}"
  36. CornerRadius="{TemplateBinding CornerRadius}"
  37. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  38. UseLayoutRounding="{TemplateBinding UseLayoutRounding}">
  39. <Grid>
  40. <Grid.ColumnDefinitions>
  41. <ColumnDefinition Width="*" />
  42. <ColumnDefinition Width="auto" />
  43. </Grid.ColumnDefinitions>
  44. <ScrollViewer x:Name="PART_ContentHost"
  45. Margin="{TemplateBinding Padding}"
  46. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  47. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  48. HorizontalScrollBarVisibility="Hidden"
  49. VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}" />
  50. <Path x:Name="PART_ErrorPath" Grid.Column="1" Visibility="Collapsed" Margin="2,0,5,0"
  51. Data="{StaticResource Error}" Stretch="Uniform"
  52. Width="15" Fill="{TemplateBinding ErrorBackground}" />
  53. <ZUI:Poptip StaysOpen="True" PlacementTarget="{Binding ElementName=Border}"
  54. IsOpen="{Binding IsShowErrorTip, Mode=OneWay, RelativeSource={RelativeSource Mode=TemplatedParent}}"
  55. Background="{TemplateBinding ErrorBackground}" PlacementEx="TopLeft" BorderThickness="0">
  56. <ContentPresenter Content="{TemplateBinding ErrorContent}"
  57. ContentTemplate="{TemplateBinding ErrorContentTemplate}"/>
  58. </ZUI:Poptip>
  59. </Grid>
  60. <!--<VisualStateManager.VisualStateGroups>
  61. <VisualStateGroup x:Name="CommonStates">
  62. <VisualState x:Name="Normal">
  63. <Storyboard>
  64. <ColorAnimation Duration="0:0:0.0" Storyboard.TargetName="Border"
  65. Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
  66. To="#ABADB3" />
  67. </Storyboard>
  68. </VisualState>
  69. <VisualState x:Name="InputError">
  70. <Storyboard>
  71. <ColorAnimation Duration="0:0:0.0" Storyboard.TargetName="Border"
  72. Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
  73. To="#E20000" />
  74. </Storyboard>
  75. </VisualState>
  76. </VisualStateGroup>
  77. </VisualStateManager.VisualStateGroups>-->
  78. </Border>
  79. <ControlTemplate.Triggers>
  80. <Trigger Property="IsMouseOver" Value="True">
  81. <Setter Property="BorderBrush" Value="#5CADFF" />
  82. </Trigger>
  83. <Trigger Property="IsKeyboardFocused" Value="True">
  84. <Setter Property="BorderBrush" Value="Blue" />
  85. </Trigger>
  86. <Trigger Property="IsHasError" Value="True">
  87. <Setter Property="BorderBrush" Value="#E20000" />
  88. <Setter TargetName="PART_ErrorPath" Property="Visibility" Value="Visible" />
  89. </Trigger>
  90. <MultiTrigger>
  91. <MultiTrigger.Conditions>
  92. <Condition Property="IsHasError" Value="True" />
  93. <Condition Property="IsMouseOver" Value="False" />
  94. </MultiTrigger.Conditions>
  95. <Setter Property="BorderBrush" Value="#E20000" />
  96. </MultiTrigger>
  97. <MultiTrigger>
  98. <MultiTrigger.Conditions>
  99. <Condition Property="IsKeyboardFocused" Value="True" />
  100. <Condition Property="IsHasError" Value="False" />
  101. <Condition Property="IsMouseOver" Value="False" />
  102. </MultiTrigger.Conditions>
  103. <Setter Property="BorderBrush" Value="Blue" />
  104. </MultiTrigger>
  105. </ControlTemplate.Triggers>
  106. </ControlTemplate>
  107. </Setter.Value>
  108. </Setter>
  109. <Style.Triggers>
  110. <Trigger Property="IsEnabled" Value="False">
  111. <Setter Property="Background" Value="{StaticResource Color.Disabled.Background}" />
  112. </Trigger>
  113. </Style.Triggers>
  114. </Style>
  115. </ResourceDictionary>