EditableTextBlock.xaml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <UserControl x:Class="AIPractice.LabelEditor.EditableTextBlock"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:AIPractice.LabelEditor"
  7. mc:Ignorable="d"
  8. d:DesignHeight="450" d:DesignWidth="800">
  9. <Grid Height="28">
  10. <Grid.ColumnDefinitions>
  11. <ColumnDefinition/>
  12. <ColumnDefinition Width="28"/>
  13. </Grid.ColumnDefinitions>
  14. <TextBlock Grid.Column="0" x:Name="Text" Text="{Binding Path=Value,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:EditableTextBlock}}}" VerticalAlignment="Center" Visibility="Visible"/>
  15. <TextBox Grid.Column="0" x:Name="Box" Text="{Binding Path=Value,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:EditableTextBlock}}}" VerticalAlignment="Center" KeyDown="OnBoxKeyDown" Visibility="Collapsed"/>
  16. <ToggleButton x:Name="EditSwitch" Grid.Column="1" Width="20" Height="20" Checked="OnChecked" Unchecked="OnUnchecked">
  17. <ToggleButton.Template>
  18. <ControlTemplate>
  19. <Border x:Name="ButtonBorder" CornerRadius="2">
  20. <Image x:Name="ButtonImage" Source="Resources/Images/Edit.png" Width="16" Height="16"/>
  21. </Border>
  22. <ControlTemplate.Triggers>
  23. <Trigger Property="ToggleButton.IsMouseOver" Value="True">
  24. <Setter TargetName="ButtonBorder" Property="BorderThickness" Value="1"/>
  25. <Setter TargetName="ButtonBorder" Property="BorderBrush" Value="CadetBlue"/>
  26. </Trigger>
  27. <Trigger Property="ToggleButton.IsPressed" Value="True">
  28. <Setter TargetName="ButtonBorder" Property="Background" Value="Azure"/>
  29. </Trigger>
  30. <Trigger Property="ToggleButton.IsChecked" Value="True">
  31. <Setter TargetName="ButtonImage" Property="Source" Value="Resources/Images/Ok.png"/>
  32. </Trigger>
  33. <Trigger Property="ToggleButton.IsChecked" Value="False">
  34. <Setter TargetName="ButtonImage" Property="Source" Value="Resources/Images/Edit.png"/>
  35. </Trigger>
  36. </ControlTemplate.Triggers>
  37. </ControlTemplate>
  38. </ToggleButton.Template>
  39. </ToggleButton>
  40. </Grid>
  41. </UserControl>