TextBoxWithTip.xaml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <UserControl
  2. x:Class="PDF_Master.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_Master.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 MaxHeight="30" />
  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, UpdateSourceTrigger=PropertyChanged}" />
  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. TextWrapping="Wrap"
  35. Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=ShowTip}" />
  36. </Grid>
  37. <ControlTemplate.Triggers>
  38. <Trigger SourceName="TextBox" Property="IsError" Value="True">
  39. <Setter TargetName="TbTip" Property="Foreground" Value="{StaticResource color.field.text.tips-error}" />
  40. </Trigger>
  41. </ControlTemplate.Triggers>
  42. </ControlTemplate>
  43. </Setter.Value>
  44. </Setter>
  45. </Style>
  46. </UserControl.Style>
  47. </UserControl>