This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -0,0 +1,75 @@
<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>