提交记录修改UI/Controls/Input/InputBox.cs+27 −0看文件
修改UI/Themes/Input/InputBox.xaml+33 −0看文件
| @@ -11,13 +11,40 @@ namespace UI.Controls.Input | ||
| 11 | 11 | { |
| 12 | 12 | public class InputBox : TextBox |
| 13 | 13 | { |
| 14 | 新增: public string Error { get { return (string)GetValue(ErrorProperty); } set { SetValue(ErrorProperty, value); } } | |
| 15 | 新增: public static readonly DependencyProperty ErrorProperty = DependencyProperty.Register("Error", typeof(string), typeof(InputBox)); | |
| 16 | 新增: | |
| 17 | 新增: public bool IsShowError { get { return (bool)GetValue(IsShowErrorProperty); } set { SetValue(IsShowErrorProperty, value); } } | |
| 18 | 新增: public static readonly DependencyProperty IsShowErrorProperty = DependencyProperty.Register("IsShowError", typeof(bool), typeof(InputBox)); | |
| 19 | 新增: | |
| 20 | 新增: | |
| 14 | 21 | public string Placeholder { get { return (string)GetValue(PlaceholderProperty); } set { SetValue(PlaceholderProperty, value); } } |
| 15 | 22 | public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.Register("Placeholder", typeof(string), typeof(InputBox)); |
| 23 | 新增: private Popup ErrorPopup; | |
| 16 | 24 | public InputBox() |
| 17 | 25 | { |
| 18 | 26 | DefaultStyleKey = typeof(InputBox); |
| 19 | 27 | } |
| 28 | 新增: public override void OnApplyTemplate() | |
| 29 | 新增: { | |
| 30 | 新增: base.OnApplyTemplate(); | |
| 31 | 新增: ErrorPopup = GetTemplateChild("ErrorPopup") as Popup; | |
| 32 | 新增: ErrorPopup.Closed += ErrorPopup_Closed; | |
| 33 | 新增: } | |
| 34 | 新增: | |
| 35 | 新增: private void ErrorPopup_Closed(object sender, EventArgs e) | |
| 36 | 新增: { | |
| 37 | 新增: IsShowError = false; | |
| 38 | 新增: } | |
| 20 | 39 | |
| 40 | 新增: public void ShowError() | |
| 41 | 新增: { | |
| 42 | 新增: IsShowError = true; | |
| 43 | 新增: } | |
| 21 | 44 | |
| 45 | 新增: public void HideError() | |
| 46 | 新增: { | |
| 47 | 新增: IsShowError = false; | |
| 48 | 新增: } | |
| 22 | 49 | } |
| 23 | 50 | } |
| @@ -26,7 +26,40 @@ | ||
| 26 | 26 | </Grid> |
| 27 | 27 | |
| 28 | 28 | </Border> |
| 29 | 新增: <Popup | |
| 30 | 新增: x:Name="ErrorPopup" | |
| 31 | 新增: AllowsTransparency="True" | |
| 32 | 新增: IsOpen="{TemplateBinding IsShowError}" | |
| 33 | 新增: Placement="Bottom" | |
| 34 | 新增: PlacementTarget="{Binding ElementName=BoxBorder}" | |
| 35 | 新增: PopupAnimation="Slide" | |
| 36 | 新增: StaysOpen="False"> | |
| 37 | 新增: <Border | |
| 38 | 新增: Background="Red" | |
| 39 | 新增: CornerRadius="12" | |
| 40 | 新增: Padding="10" | |
| 41 | 新增: Margin="10"> | |
| 42 | 新增: <Border.Effect> | |
| 43 | 新增: <DropShadowEffect BlurRadius="10" ShadowDepth="0" Direction="0" Color="Gray" Opacity=".2"/> | |
| 44 | 新增: </Border.Effect> | |
| 29 | 45 | |
| 46 | 新增: <Grid> | |
| 47 | 新增: <Path | |
| 48 | 新增: Width="15" | |
| 49 | 新增: Height="15" | |
| 50 | 新增: SnapsToDevicePixels="False" | |
| 51 | 新增: Data="M 0 15 L 7.5 7.5 L 15 15" Fill="Red" | |
| 52 | 新增: Stroke="Red" | |
| 53 | 新增: StrokeThickness="1" | |
| 54 | 新增: VerticalAlignment="Top" | |
| 55 | 新增: HorizontalAlignment="Left" | |
| 56 | 新增: Margin="0,-25,0,0" | |
| 57 | 新增: /> | |
| 58 | 新增: <TextBlock Foreground="White" Text="{TemplateBinding Error}"/> | |
| 59 | 新增: </Grid> | |
| 60 | 新增: | |
| 61 | 新增: </Border> | |
| 62 | 新增: </Popup> | |
| 30 | 63 | |
| 31 | 64 | </Grid> |
| 32 | 65 | <VisualStateManager.VisualStateGroups> |

