<UserControl x:Class="PixiEditor.Views.UserControls.EditableTextBlock"
             x:ClassModifier="internal"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters" 
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
             mc:Ignorable="d" x:Name="etb"
             d:DesignHeight="60" d:DesignWidth="100" Focusable="True">
    <Grid>
        <TextBlock Foreground="{Binding ElementName=etb, Path=Foreground}" MouseLeftButtonDown="TextBlock_MouseDown"
                   TextTrimming="CharacterEllipsis" Name="textBlock"
                   Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
                   Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Mode=TwoWay}" />
        <TextBox Foreground="{Binding ElementName=etb, Path=Foreground}"
                 MaxLength="{Binding Path=MaxChars, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Mode=TwoWay}" Style="{StaticResource DarkTextBoxStyle}"
                 LostFocus="TextBox_LostFocus"
                 Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Mode=TwoWay}"
                 KeyDown="TextBox_KeyDown"
                 LostKeyboardFocus="TextBox_LostKeyboardFocus"
                 Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, 
                                      Converter={converters:OppositeVisibilityConverter}}"
                 Name="textBox">
            <i:Interaction.Behaviors>
                <behaviours:GlobalShortcutFocusBehavior/>
            </i:Interaction.Behaviors>
        </TextBox>
    </Grid>
</UserControl>
