75 lines
4.5 KiB
XML
75 lines
4.5 KiB
XML
<ResourceDictionary x:Class="WPFDark.Controls.BiaEditableTextBlockEventHandler"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:controls="clr-namespace:WPFDark.Controls"
|
|
xmlns:internals="clr-namespace:WPFDark.Internals"
|
|
xmlns:wpf="clr-namespace:WPFDark">
|
|
<ResourceDictionary.MergedDictionaries>
|
|
<internals:SharedResourceDictionary Source="pack://application:,,,/WPFDark;component/Controls/BiaTextBlock.xaml" />
|
|
<internals:SharedResourceDictionary Source="pack://application:,,,/WPFDark;component/StandardControls/TextBox.xaml" />
|
|
</ResourceDictionary.MergedDictionaries>
|
|
|
|
<Style x:Key="TextBoxStyle"
|
|
BasedOn="{StaticResource {x:Type TextBox}}"
|
|
TargetType="{x:Type TextBox}">
|
|
<EventSetter Event="Loaded" Handler="TextBox_Loaded" />
|
|
<EventSetter Event="LostFocus" Handler="TextBox_LostFocus" />
|
|
<EventSetter Event="PreviewKeyDown" Handler="TextBox_PreviewKeyDown" />
|
|
<EventSetter Event="PreviewMouseDown" Handler="TextBox_PreviewMouseDown" />
|
|
|
|
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=Foreground}" />
|
|
<Setter Property="Text" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=TwoWay, Path=Text}" />
|
|
</Style>
|
|
|
|
<Style x:Key="TextBlockStyle"
|
|
BasedOn="{StaticResource {x:Type controls:BiaTextBlock}}"
|
|
TargetType="{x:Type controls:BiaTextBlock}">
|
|
<EventSetter Event="MouseDown" Handler="TextBlock_OnMouseDown" />
|
|
|
|
<Setter Property="IsHitTestVisible" Value="True" />
|
|
|
|
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=Foreground}" />
|
|
<Setter Property="Text" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=Text}" />
|
|
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=Text}" Value="{x:Null}">
|
|
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=WatermarkForeground}" />
|
|
<Setter Property="Text" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=Watermark}" />
|
|
</DataTrigger>
|
|
|
|
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=Text}" Value="">
|
|
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=WatermarkForeground}" />
|
|
<Setter Property="Text" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:BiaEditableTextBlock}}, Mode=OneWay, Path=Watermark}" />
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
|
|
<Style TargetType="{x:Type controls:BiaEditableTextBlock}">
|
|
<Setter Property="Foreground" Value="{DynamicResource ForegroundBrushKey}" />
|
|
<Setter Property="WatermarkForeground" Value="{DynamicResource TextBoxSubForegroundBrushKey}" />
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="Cursor" Value="Hand" />
|
|
|
|
<Style.Triggers>
|
|
<Trigger Property="IsEditing" Value="True">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate>
|
|
<TextBox Style="{StaticResource TextBoxStyle}" />
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Trigger>
|
|
|
|
<Trigger Property="IsEditing" Value="False">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate>
|
|
<controls:BiaTextBlock Style="{StaticResource TextBlockStyle}" />
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</ResourceDictionary> |