<UserControl x:Class="PDF_Master.CustomControl.TextBoxWithTip" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:PDF_Master.CustomControl" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> <UserControl.Style> <Style TargetType="{x:Type UserControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition MaxHeight="30" /> </Grid.RowDefinitions> <local:TextBoxEx x:Name="TextBox" IsError="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=IsError}" PlaceholderText="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=PlaceHoldText}" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=Text, UpdateSourceTrigger=PropertyChanged}" /> <TextBlock Name="TbTip" Grid.Row="1" Margin="0,2,0,0" FontFamily="Segoe UI" FontSize="12" Foreground="{StaticResource color.field.text.tips}" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=TipText}" TextWrapping="Wrap" Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TextBoxWithTip}, Path=ShowTip}" /> </Grid> <ControlTemplate.Triggers> <Trigger SourceName="TextBox" Property="IsError" Value="True"> <Setter TargetName="TbTip" Property="Foreground" Value="{StaticResource color.field.text.tips-error}" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Style> </UserControl>