TextBoxWithTip.xaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <UserControl
  2. x:Class="PDF_Office.CustomControl.TextBoxWithTip"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:PDF_Office.CustomControl"
  7. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8. d:DesignHeight="450"
  9. d:DesignWidth="800"
  10. mc:Ignorable="d">
  11. <UserControl.Style>
  12. <Style TargetType="{x:Type UserControl}">
  13. <Setter Property="Template">
  14. <Setter.Value>
  15. <ControlTemplate>
  16. <Grid>
  17. <Grid.RowDefinitions>
  18. <RowDefinition Height="*" />
  19. <RowDefinition Height="20" />
  20. </Grid.RowDefinitions>
  21. <local:TextBoxEx
  22. x:Name="TextBox"
  23. IsError="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=IsError}"
  24. PlaceholderText="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=PlaceHoldText}"
  25. Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=Text}" />
  26. <TextBlock
  27. Name="TbTip"
  28. Grid.Row="1"
  29. Margin="0,2,0,0"
  30. FontFamily="Segoe UI"
  31. FontSize="12"
  32. Foreground="{StaticResource color.field.text.tips}"
  33. Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=TipText}"
  34. Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=ShowTip}" />
  35. </Grid>
  36. <ControlTemplate.Triggers>
  37. <Trigger SourceName="TextBox" Property="IsError" Value="True">
  38. <Setter TargetName="TbTip" Property="Foreground" Value="{StaticResource color.field.text.tips-error}" />
  39. </Trigger>
  40. </ControlTemplate.Triggers>
  41. </ControlTemplate>
  42. </Setter.Value>
  43. </Setter>
  44. </Style>
  45. </UserControl.Style>
  46. </UserControl>