1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <UserControl x:Class="AIPractice.LabelEditor.EditableTextBlock"
- 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:local="clr-namespace:AIPractice.LabelEditor"
- mc:Ignorable="d"
- d:DesignHeight="450" d:DesignWidth="800">
- <Grid Height="28">
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition Width="28"/>
- </Grid.ColumnDefinitions>
- <TextBlock Grid.Column="0" x:Name="Text" Text="{Binding Path=Value,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:EditableTextBlock}}}" VerticalAlignment="Center" Visibility="Visible"/>
- <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"/>
- <ToggleButton x:Name="EditSwitch" Grid.Column="1" Width="20" Height="20" Checked="OnChecked" Unchecked="OnUnchecked">
- <ToggleButton.Template>
- <ControlTemplate>
- <Border x:Name="ButtonBorder" CornerRadius="2">
- <Image x:Name="ButtonImage" Source="Resources/Images/Edit.png" Width="16" Height="16"/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="ToggleButton.IsMouseOver" Value="True">
- <Setter TargetName="ButtonBorder" Property="BorderThickness" Value="1"/>
- <Setter TargetName="ButtonBorder" Property="BorderBrush" Value="CadetBlue"/>
- </Trigger>
- <Trigger Property="ToggleButton.IsPressed" Value="True">
- <Setter TargetName="ButtonBorder" Property="Background" Value="Azure"/>
- </Trigger>
- <Trigger Property="ToggleButton.IsChecked" Value="True">
- <Setter TargetName="ButtonImage" Property="Source" Value="Resources/Images/Ok.png"/>
- </Trigger>
- <Trigger Property="ToggleButton.IsChecked" Value="False">
- <Setter TargetName="ButtonImage" Property="Source" Value="Resources/Images/Edit.png"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </ToggleButton.Template>
- </ToggleButton>
- </Grid>
- </UserControl>
|