Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. [Required(ErrorMessage = "Login field should be filled in")]
  2. [RegularExpression(@"w+(@)[a-zA-z]+(.)[a-zA-z]+", ErrorMessage = ("Use the right email format"))]
  3. public string Email
  4. {
  5. get => authRequstModel.Email;
  6. set => Set(ref authRequstModel.Email, value);
  7. }
  8.  
  9. <TextBox x:Name="email" Style="{StaticResource emaliStyle}" Grid.Column="2" Grid.Row="2">
  10. <TextBox.Text>
  11. <Binding Mode="TwoWay" Path="Email" UpdateSourceTrigger="PropertyChanged">
  12. <Binding.ValidationRules>
  13. <DataErrorValidationRule ValidatesOnTargetUpdated="False"/>
  14. </Binding.ValidationRules>
  15. </Binding>
  16. </TextBox.Text>
  17. </TextBox>
  18.  
  19. <Style TargetType="TextBox" x:Key="emaliStyle">
  20. <Setter Property="Width" Value="204"/>
  21. <Setter Property="Height" Value="30"/>
  22. <Setter Property="FontSize" Value="18"/>
  23. <Setter Property="HorizontalAlignment" Value="Left"/>
  24. <Setter Property="VerticalAlignment" Value="Center"/>
  25. <Setter Property="FontSize" Value="20"/>
  26. <Setter Property="Padding" Value="5,2,1,0"/>
  27. <Setter Property="SelectionBrush" Value="Red"/>
  28. <Setter x:Name="LoginValidation" Property="Validation.ErrorTemplate">
  29. <Setter.Value>
  30. <ControlTemplate>
  31. <DockPanel LastChildFill="True">
  32. <TextBlock DockPanel.Dock="Bottom" Foreground="Maroon" FontSize="8pt"
  33. Text="{Binding ElementName=email, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
  34. </TextBlock>
  35. <Border BorderBrush="DarkRed" BorderThickness="2" CornerRadius="10">
  36. <AdornedElementPlaceholder Name="email" />
  37. </Border>
  38. </DockPanel>
  39. </ControlTemplate>
  40. </Setter.Value>
  41. </Setter>
  42. </Style>
  43.  
  44. <Style TargetType="TextBox" x:Key="emaliStyle">
  45. <Setter Property="Width" Value="204"/>
  46. <Setter Property="Height" Value="30"/>
  47. <Setter Property="FontSize" Value="18"/>
  48. <Setter Property="HorizontalAlignment" Value="Left"/>
  49. <Setter Property="VerticalAlignment" Value="Center"/>
  50. <Setter Property="FontSize" Value="20"/>
  51. <Setter Property="Padding" Value="5,2,1,0"/>
  52. <Setter Property="SelectionBrush" Value="Red"/>
  53. <Setter Property="BorderThickness" Value="2" />
  54. <Setter Property="BorderBrush" Value="Green" />
  55. <Setter x:Name="LoginValidation" Property="Validation.ErrorTemplate">
  56. <Setter.Value>
  57. <ControlTemplate>
  58. <DockPanel LastChildFill="True">
  59. <TextBlock DockPanel.Dock="Bottom" Foreground="Maroon" FontSize="8pt"
  60. Text="{Binding ElementName=Email, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
  61. </TextBlock>
  62. <AdornedElementPlaceholder Name="email" />
  63. </DockPanel>
  64. </ControlTemplate>
  65. </Setter.Value>
  66. </Setter>
  67. <Setter Property="Template">
  68. <Setter.Value>
  69. <ControlTemplate TargetType="{x:Type TextBox}">
  70. <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}"
  71. BorderThickness="{TemplateBinding BorderThickness}"
  72. Background="{TemplateBinding Background}"
  73. CornerRadius="10"
  74. SnapsToDevicePixels="True">
  75. <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
  76. </Border>
  77. <ControlTemplate.Triggers>
  78. <Trigger Property="IsEnabled" Value="false">
  79. <Setter Property="Opacity" TargetName="border" Value="0.56"/>
  80. </Trigger>
  81. </ControlTemplate.Triggers>
  82. </ControlTemplate>
  83. </Setter.Value>
  84. </Setter>
  85. <Style.Triggers>
  86. <Trigger Property="Validation.HasError" Value="True">
  87. <Setter Property="BorderBrush" Value="DarkRed" />
  88. </Trigger>
  89. </Style.Triggers>
  90. </Style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement