mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
100 lines
6.2 KiB
XML
100 lines
6.2 KiB
XML
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner">
|
||
<!--TextBox水印样式-->
|
||
<Style TargetType="{x:Type TextBox}" x:Key="WaterTextBox">
|
||
<Setter Property="Background" Value="Transparent"/>
|
||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||
<Setter Property="Width" Value="Auto"/>
|
||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||
<Grid x:Name="PART_Root">
|
||
<Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
Background="{TemplateBinding Background}" />
|
||
<Grid x:Name="PART_InnerGrid">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="Auto" />
|
||
<ColumnDefinition Width="*" />
|
||
<ColumnDefinition Width="Auto" />
|
||
</Grid.ColumnDefinitions>
|
||
|
||
<!--内容区域-->
|
||
<ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Grid.Column="1" IsTabStop="False" Margin="2"
|
||
VerticalAlignment="Stretch" Background="{x:Null}" >
|
||
</ScrollViewer>
|
||
<!--水印-->
|
||
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
|
||
Text="{TemplateBinding s:ControlAttachProperty.Watermark}" Grid.Column="1"
|
||
Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" Opacity="0.5"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />
|
||
</Grid>
|
||
</Grid>
|
||
<ControlTemplate.Triggers>
|
||
<!--显示水印-->
|
||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
|
||
<Setter TargetName="Message" Property="Visibility" Value="Visible" />
|
||
</DataTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
|
||
<!--TextBox水印,阴影样式-->
|
||
<Style TargetType="{x:Type TextBox}" x:Key="WaterTextBoxWithEffect">
|
||
<Setter Property="Background" Value="Transparent"/>
|
||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||
<Setter Property="Width" Value="Auto"/>
|
||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||
<Setter Property="BorderThickness" Value="0"/>
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||
<Grid x:Name="PART_Root">
|
||
<Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
Background="{TemplateBinding Background}" />
|
||
<Grid x:Name="PART_InnerGrid">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="Auto" />
|
||
<ColumnDefinition Width="*" />
|
||
<ColumnDefinition Width="Auto" />
|
||
</Grid.ColumnDefinitions>
|
||
|
||
<!--内容区域-->
|
||
<ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Grid.Column="1" IsTabStop="False" Margin="2"
|
||
VerticalAlignment="Stretch" Background="{x:Null}" >
|
||
<ScrollViewer.Effect>
|
||
<DropShadowEffect x:Name="effect" Color="{Binding FontViewModel.TextEffectColor}" ></DropShadowEffect>
|
||
</ScrollViewer.Effect>
|
||
</ScrollViewer>
|
||
<!--水印-->
|
||
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
|
||
Text="{TemplateBinding s:ControlAttachProperty.Watermark}" Grid.Column="1"
|
||
Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" Opacity="0.5"
|
||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />
|
||
</Grid>
|
||
</Grid>
|
||
<ControlTemplate.Triggers>
|
||
<!--显示水印-->
|
||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
|
||
<Setter TargetName="Message" Property="Visibility" Value="Visible" />
|
||
</DataTrigger>
|
||
<DataTrigger Binding="{Binding FontViewModel.TextEffectColor}" Value="Transparent">
|
||
<Setter TargetName="PART_ContentHost" Property="Effect" Value="{x:Null}"/>
|
||
</DataTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
</ResourceDictionary> |