A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
2.6 KiB

<Styles xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XamlTestApplication;assembly=XamlTestApplicationPcl">
<Style Selector="TextBox">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="#ff707070"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Template">
<ControlTemplate>
<Border Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="2">
<ScrollViewer CanScrollHorizontally="{TemplateBinding CanScrollHorizontally}"
HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}">
<StackPanel Margin="{TemplateBinding Padding}">
<TextBlock Name="floatingWatermark"
Foreground="#ff007ACC"
FontSize="10"
Text="{TemplateBinding Watermark}"
IsVisible="{TemplateBinding FloatingWatermark}">
</TextBlock>
<Panel>
<TextBlock Name="watermark"
Opacity="0.5"
Text="{TemplateBinding Watermark}"
IsVisible="{TemplateBinding IsWatermarkVisible}">
<TextBlock.IsVisible>
<Binding RelativeSource="{RelativeSource TemplatedParent}"
SourcePropertyPath="Text"
Converter="{Static local:StringNullOrEmpty.Instance}"/>
</TextBlock.IsVisible>
</TextBlock>
<TextPresenter Name="PART_TextPresenter"
CaretIndex="{TemplateBinding CaretIndex}"
SelectionStart="{TemplateBinding SelectionStart}"
SelectionEnd="{TemplateBinding SelectionEnd}"
Text="{TemplateBinding Text}"
TextWrapping="{TemplateBinding TextWrapping}"/>
</Panel>
</StackPanel>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="TextBox:focus /template/ Border#border">
<Setter Property="BorderBrush" Value="Black"/>
</Style>
</Styles>