csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
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.
159 lines
8.1 KiB
159 lines
8.1 KiB
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
<Design.PreviewWith>
|
|
<Border Padding="20">
|
|
<TextBox Text="Sample"
|
|
FontSize="20"
|
|
Width="100"
|
|
TextAlignment="Center"/>
|
|
</Border>
|
|
</Design.PreviewWith>
|
|
|
|
<Styles.Resources>
|
|
<Thickness x:Key="TextBoxTopHeaderMargin">0,0,0,4</Thickness>
|
|
</Styles.Resources>
|
|
<Style Selector="TextBox">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
|
|
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
|
|
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
|
|
<Setter Property="SelectionBrush" Value="{DynamicResource TextControlSelectionHighlightColor}" />
|
|
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
|
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
|
|
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
|
|
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
|
|
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
|
|
<Setter Property="Template">
|
|
<ControlTemplate>
|
|
<DockPanel>
|
|
|
|
<!-- TODO bind Content -> Header and ContentTemplate -> HeaderTemplate -->
|
|
<ContentPresenter x:Name="HeaderContentPresenter"
|
|
DockPanel.Dock="Top"
|
|
TextBlock.FontWeight="Normal"
|
|
TextBlock.Foreground="{DynamicResource TextControlHeaderForeground}"
|
|
IsVisible="False"
|
|
Margin="{DynamicResource TextBoxTopHeaderMargin}" />
|
|
|
|
<Panel>
|
|
<Border
|
|
Name="border"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="{DynamicResource ControlCornerRadius}"
|
|
MinWidth="{TemplateBinding MinWidth}"
|
|
MinHeight="{TemplateBinding MinHeight}">
|
|
</Border>
|
|
|
|
<Border
|
|
Padding="{TemplateBinding Padding}"
|
|
Margin="{TemplateBinding BorderThickness}">
|
|
<DockPanel>
|
|
<TextBlock Name="floatingWatermark"
|
|
Foreground="{DynamicResource SystemAccentColor}"
|
|
FontSize="{TemplateBinding FontSize}"
|
|
Text="{TemplateBinding Watermark}"
|
|
DockPanel.Dock="Top">
|
|
<TextBlock.IsVisible>
|
|
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
|
<Binding RelativeSource="{RelativeSource TemplatedParent}"
|
|
Path="UseFloatingWatermark"/>
|
|
<Binding RelativeSource="{RelativeSource TemplatedParent}"
|
|
Path="Text"
|
|
Converter="{x:Static StringConverters.IsNotNullOrEmpty}"/>
|
|
</MultiBinding>
|
|
</TextBlock.IsVisible>
|
|
</TextBlock>
|
|
|
|
<DataValidationErrors>
|
|
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
|
|
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
|
|
|
|
<Panel>
|
|
<TextBlock Name="watermark"
|
|
Opacity="0.5"
|
|
Text="{TemplateBinding Watermark}"
|
|
TextAlignment="{TemplateBinding TextAlignment}"
|
|
TextWrapping="{TemplateBinding TextWrapping}"
|
|
IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
|
<!-- TODO eliminate this margin... text layout issue? -->
|
|
<TextPresenter Name="PART_TextPresenter"
|
|
Margin="0 1 0 0"
|
|
Text="{TemplateBinding Text, Mode=TwoWay}"
|
|
CaretIndex="{TemplateBinding CaretIndex}"
|
|
SelectionStart="{TemplateBinding SelectionStart}"
|
|
SelectionEnd="{TemplateBinding SelectionEnd}"
|
|
TextAlignment="{TemplateBinding TextAlignment}"
|
|
TextWrapping="{TemplateBinding TextWrapping}"
|
|
PasswordChar="{TemplateBinding PasswordChar}"
|
|
SelectionBrush="{TemplateBinding SelectionBrush}"
|
|
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
|
|
CaretBrush="{TemplateBinding CaretBrush}"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
|
</Panel>
|
|
</ScrollViewer>
|
|
</DataValidationErrors>
|
|
</DockPanel>
|
|
</Border>
|
|
</Panel>
|
|
</DockPanel>
|
|
</ControlTemplate>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<!-- Disabled State -->
|
|
<Style Selector="TextBox:disabled">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="TextBox:disabled /template/ Border#border">
|
|
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
|
</Style>
|
|
|
|
<Style Selector="TextBox:disabled /template/ TextBlock#watermark, TextBox:disabled /template/ TextBlock#floatingWatermark">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundDisabled}" />
|
|
</Style>
|
|
|
|
<!-- PointerOver State-->
|
|
<Style Selector="TextBox:disabled">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="TextBox:pointerover /template/ Border#border">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushPointerOver}"/>
|
|
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
|
|
</Style>
|
|
|
|
<Style Selector="TextBox:pointerover /template/ TextBlock#watermark, TextBox:pointerover /template/ TextBlock#floatingWatermark">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundPointerOver}" />
|
|
</Style>
|
|
|
|
<!-- Focused State -->
|
|
<Style Selector="TextBox:focus">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundFocused}" />
|
|
</Style>
|
|
|
|
<Style Selector="TextBox:focus /template/ TextBlock#watermark, TextBox:focus /template/ TextBlock#floatingWatermark">
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundFocused}" />
|
|
</Style>
|
|
|
|
<Style Selector="TextBox:focus /template/ Border#border">
|
|
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundFocused}"/>
|
|
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushFocused}"/>
|
|
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThicknessFocused}" />
|
|
</Style>
|
|
|
|
|
|
<Style Selector="TextBox:error /template/ Border#border">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/>
|
|
</Style>
|
|
|
|
<Style Selector="TextBox /template/ DockPanel">
|
|
<Setter Property="Cursor" Value="IBeam" />
|
|
</Style>
|
|
|
|
</Styles>
|
|
|