Add PlaceholderForeground property to TextBox, AutoCompleteBox, CalendarDatePicker, NumericUpDown (#20303)
* Added WatermarkForeground property * Added samples * Added unit tests * Added render tests * Fix merge issues * Updated render tests * Standardize watermark foreground naming * Pending changes * More changes * Use UseFloatingPlaceholder * Fix tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
|
||||
x:Class="BindingDemo.MainWindow"
|
||||
xmlns:vm="using:BindingDemo.ViewModels"
|
||||
xmlns:vm="using:BindingDemo.ViewModels"
|
||||
xmlns:local="using:BindingDemo"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
Title="AvaloniaUI Bindings Test"
|
||||
@@ -13,29 +13,29 @@
|
||||
<Setter Property="FontSize" Value="18"/>
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
|
||||
|
||||
<TabControl>
|
||||
<TabItem Header="Basic">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Margin="18" Spacing="4" Width="200">
|
||||
<TextBlock FontSize="16" Text="Simple Bindings"/>
|
||||
<TextBox Watermark="Two Way" UseFloatingWatermark="True" Text="{Binding Path=StringValue}" Name="first"/>
|
||||
<TextBox Watermark="Two Way (LostFocus)" UseFloatingWatermark="True" Text="{Binding Path=StringValue, UpdateSourceTrigger=LostFocus}"/>
|
||||
<TextBox Watermark="One Way" UseFloatingWatermark="True" Text="{Binding Path=StringValue, Mode=OneWay}"/>
|
||||
<TextBox Watermark="One Time" UseFloatingWatermark="True" Text="{Binding Path=StringValue, Mode=OneTime}"/>
|
||||
<TextBox PlaceholderText="Two Way" UseFloatingPlaceholder="True" Text="{Binding Path=StringValue}" Name="first"/>
|
||||
<TextBox PlaceholderText="Two Way (LostFocus)" UseFloatingPlaceholder="True" Text="{Binding Path=StringValue, UpdateSourceTrigger=LostFocus}"/>
|
||||
<TextBox PlaceholderText="One Way" UseFloatingPlaceholder="True" Text="{Binding Path=StringValue, Mode=OneWay}"/>
|
||||
<TextBox PlaceholderText="One Time" UseFloatingPlaceholder="True" Text="{Binding Path=StringValue, Mode=OneTime}"/>
|
||||
<!-- Removed due to #2983: reinstate when that's fixed.
|
||||
<TextBox Watermark="One Way to Source" UseFloatingWatermark="True" Text="{Binding Path=StringValue, Mode=OneWayToSource}"/>
|
||||
<TextBox Placeholder="One Way to Source" UseFloatingPlaceholder="True" Text="{Binding Path=StringValue, Mode=OneWayToSource}"/>
|
||||
-->
|
||||
</StackPanel>
|
||||
<StackPanel Margin="18" Spacing="4" Width="200">
|
||||
<TextBlock FontSize="16" Text="Collection Bindings"/>
|
||||
<TextBox Watermark="Items[1].Value" UseFloatingWatermark="True" Text="{Binding Path=Items[1].Value}"/>
|
||||
<TextBox PlaceholderText="Items[1].Value" UseFloatingPlaceholder="True" Text="{Binding Path=Items[1].Value}"/>
|
||||
<Button Command="{Binding ShuffleItems}">Shuffle</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="18" Spacing="4" Width="200">
|
||||
<TextBlock FontSize="16" Text="Negated Bindings"/>
|
||||
<TextBox Watermark="Boolean String" UseFloatingWatermark="True" Text="{Binding Path=BooleanString}"/>
|
||||
<TextBox PlaceholderText="Boolean String" UseFloatingPlaceholder="True" Text="{Binding Path=BooleanString}"/>
|
||||
<CheckBox IsChecked="{Binding !BooleanString}">!BooleanString</CheckBox>
|
||||
<CheckBox IsChecked="{Binding !!BooleanString}">!!BooleanString</CheckBox>
|
||||
</StackPanel>
|
||||
@@ -43,24 +43,24 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Margin="18" Spacing="4" Width="200" HorizontalAlignment="Left">
|
||||
<TextBlock FontSize="16" Text="Numeric Bindings"/>
|
||||
<TextBox Watermark="Double" UseFloatingWatermark="True" Text="{Binding Path=DoubleValue, Mode=TwoWay}"/>
|
||||
<TextBox PlaceholderText="Double" UseFloatingPlaceholder="True" Text="{Binding Path=DoubleValue, Mode=TwoWay}"/>
|
||||
<TextBlock Text="{Binding Path=DoubleValue}"/>
|
||||
<ProgressBar Maximum="10" Value="{Binding DoubleValue}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="18" Spacing="4" Width="200" HorizontalAlignment="Left">
|
||||
<TextBlock FontSize="16" Text="Binding Sources"/>
|
||||
<TextBox Watermark="Value of first TextBox" UseFloatingWatermark="True"
|
||||
<TextBox PlaceholderText="Value of first TextBox" UseFloatingPlaceholder="True"
|
||||
Text="{Binding #first.Text, Mode=TwoWay}"/>
|
||||
<TextBox Watermark="Value of SharedItem.StringValue" UseFloatingWatermark="True"
|
||||
<TextBox PlaceholderText="Value of SharedItem.StringValue" UseFloatingPlaceholder="True"
|
||||
Text="{Binding Value, Source={StaticResource SharedItem}, Mode=TwoWay, DataType={x:Type vm:MainWindowViewModel+TestItem, x:TypeArguments=x:String}}"/>
|
||||
<TextBox Watermark="Value of SharedItem.StringValue (duplicate)" UseFloatingWatermark="True"
|
||||
<TextBox PlaceholderText="Value of SharedItem.StringValue (duplicate)" UseFloatingPlaceholder="True"
|
||||
Text="{Binding Value, Source={StaticResource SharedItem}, Mode=TwoWay, DataType={x:Type vm:MainWindowViewModel+TestItem, x:TypeArguments=x:String}}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="18" Spacing="4" Width="200" HorizontalAlignment="Left">
|
||||
<TextBlock FontSize="16" Text="Scheduler"/>
|
||||
<TextBox Watermark="Background Thread" Text="{Binding CurrentTime, Mode=OneWay}"/>
|
||||
<TextBox PlaceholderText="Background Thread" Text="{Binding CurrentTime, Mode=OneWay}"/>
|
||||
<TextBlock FontSize="16" Text="Stream Operator"/>
|
||||
<TextBox Watermark="StreamOperator" Text="{CompiledBinding CurrentTimeObservable^, Mode=OneWay}"/>
|
||||
<TextBox PlaceholderText="StreamOperator" Text="{CompiledBinding CurrentTimeObservable^, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -91,19 +91,19 @@
|
||||
</TabItem>
|
||||
<TabItem Header="Property Validation">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Margin="18" Spacing="4" MinWidth="200" DataContext="{Binding ExceptionDataValidation}">
|
||||
<StackPanel Margin="18" Spacing="4" MinWidth="200" DataContext="{Binding ExceptionDataValidation}">
|
||||
<TextBlock FontSize="16" Text="Exception Validation"/>
|
||||
<TextBox Watermark="Less Than 10" UseFloatingWatermark="True" Text="{Binding Path=LessThan10}"/>
|
||||
<TextBox PlaceholderText="Less Than 10" UseFloatingPlaceholder="True" Text="{Binding Path=LessThan10}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="18" Spacing="4" MinWidth="200" DataContext="{Binding IndeiDataValidation}">
|
||||
<TextBlock FontSize="16" Text="INotifyDataErrorInfo Validation"/>
|
||||
<TextBox Watermark="Maximum" UseFloatingWatermark="True" Text="{Binding Path=Maximum}"/>
|
||||
<TextBox Watermark="Value" UseFloatingWatermark="True" Text="{Binding Path=Value}"/>
|
||||
<TextBox PlaceholderText="Maximum" UseFloatingPlaceholder="True" Text="{Binding Path=Maximum}"/>
|
||||
<TextBox PlaceholderText="Value" UseFloatingPlaceholder="True" Text="{Binding Path=Value}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="18" Spacing="4" MinWidth="200" DataContext="{Binding DataAnnotationsValidation}">
|
||||
<StackPanel Margin="18" Spacing="4" MinWidth="200" DataContext="{Binding DataAnnotationsValidation}">
|
||||
<TextBlock FontSize="16" Text="Data Annotations Validation"/>
|
||||
<TextBox Watermark="Phone #" UseFloatingWatermark="True" Text="{Binding PhoneNumber}"/>
|
||||
<TextBox Watermark="Less Than 10" UseFloatingWatermark="True" Text="{Binding Path=LessThan10}"/>
|
||||
<TextBox PlaceholderText="Phone #" UseFloatingPlaceholder="True" Text="{Binding PhoneNumber}"/>
|
||||
<TextBox PlaceholderText="Less Than 10" UseFloatingPlaceholder="True" Text="{Binding Path=LessThan10}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
@@ -39,8 +39,12 @@
|
||||
<AutoCompleteBox MaxDropDownHeight="60" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Watermark" />
|
||||
<AutoCompleteBox Watermark="Hello World" />
|
||||
<TextBlock Text="PlaceholderText" />
|
||||
<AutoCompleteBox PlaceholderText="Hello World" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock Text="PlaceholderText with custom color" />
|
||||
<AutoCompleteBox PlaceholderText="Search here..." PlaceholderForeground="Green" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Disabled" />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
x:Class="ControlCatalog.Pages.CalendarDatePickerPage">
|
||||
<StackPanel Orientation="Vertical" Spacing="4">
|
||||
<TextBlock Classes="h2">A control for selecting dates with a calendar drop-down</TextBlock>
|
||||
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Margin="0,16,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
@@ -32,19 +32,24 @@
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<CalendarDatePicker Margin="0,0,0,8"
|
||||
Watermark="Watermark"/>
|
||||
PlaceholderText="Placeholder"/>
|
||||
<CalendarDatePicker Margin="0,0,0,8"
|
||||
Name="DatePicker5"
|
||||
Watermark="Floating Watermark"
|
||||
UseFloatingWatermark="True"/>
|
||||
|
||||
PlaceholderText="Floating Placeholder"
|
||||
UseFloatingPlaceholder="True"/>
|
||||
|
||||
<TextBlock Text="PlaceholderText with custom color"/>
|
||||
<CalendarDatePicker Margin="0,0,0,8"
|
||||
PlaceholderText="Select a date"
|
||||
PlaceholderForeground="Purple"/>
|
||||
|
||||
<TextBlock Text="Disabled"/>
|
||||
<CalendarDatePicker IsEnabled="False"/>
|
||||
|
||||
|
||||
<TextBlock Text="Validation Example"/>
|
||||
<CalendarDatePicker SelectedDate="{CompiledBinding ValidatedDateExample, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="ControlCatalog.Pages.ClipboardPage"
|
||||
<UserControl x:Class="ControlCatalog.Pages.ClipboardPage"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StackPanel Orientation="Vertical" Spacing="4">
|
||||
@@ -21,7 +21,7 @@
|
||||
<TextBox x:Name="ClipboardContent"
|
||||
MinHeight="100"
|
||||
AcceptsReturn="True"
|
||||
Watermark="Text to copy of file names per line" />
|
||||
PlaceholderText="Text to copy of file names per line" />
|
||||
<Viewbox Width="420" Height="360">
|
||||
<Image x:Name="ClipboardImage"
|
||||
/>
|
||||
|
||||
@@ -58,17 +58,17 @@
|
||||
<Button Name="OpenBoth">Select _Both</Button>
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
|
||||
|
||||
<Expander Header="Launcher dialogs">
|
||||
<StackPanel Spacing="4">
|
||||
<TextBox Name="UriToLaunch" Watermark="Uri to launch" Text="https://avaloniaui.net/" />
|
||||
<TextBox Name="UriToLaunch" PlaceholderText="Uri to launch" Text="https://avaloniaui.net/" />
|
||||
<Button Name="LaunchUri">Launch Uri</Button>
|
||||
<Button Name="LaunchFile">Launch File</Button>
|
||||
<TextBlock Name="LaunchStatus" />
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
|
||||
<AutoCompleteBox x:Name="CurrentFolderBox" Watermark="Write full path/uri or well known folder name">
|
||||
<AutoCompleteBox x:Name="CurrentFolderBox" PlaceholderText="Write full path/uri or well known folder name">
|
||||
<AutoCompleteBox.ItemsSource>
|
||||
<generic:List x:TypeArguments="storage:WellKnownFolder">
|
||||
<storage:WellKnownFolder>Desktop</storage:WellKnownFolder>
|
||||
@@ -80,17 +80,17 @@
|
||||
</generic:List>
|
||||
</AutoCompleteBox.ItemsSource>
|
||||
</AutoCompleteBox>
|
||||
|
||||
|
||||
<TextBlock x:Name="PickerLastResultsVisible"
|
||||
Classes="h2"
|
||||
IsVisible="False"
|
||||
Text="Last picker results:" />
|
||||
<ItemsControl x:Name="PickerLastResults" />
|
||||
|
||||
<TextBox Name="BookmarkContainer" Watermark="Bookmark" />
|
||||
<TextBox Name="BookmarkContainer" PlaceholderText="Bookmark" />
|
||||
<TextBox Name="OpenedFileContent"
|
||||
MaxLines="10"
|
||||
Watermark="Picked file content" />
|
||||
PlaceholderText="Picked file content" />
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="using:System"
|
||||
xmlns:converter="using:ControlCatalog.Converter"
|
||||
@@ -48,8 +48,8 @@
|
||||
<ComboBox x:Name="CultureSelector" Grid.Row="2" Grid.Column="1" ItemsSource="{Binding Cultures}"
|
||||
VerticalAlignment="Center" Margin="2"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">Watermark:</TextBlock>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding #upDown.Watermark}" VerticalAlignment="Center" Margin="2" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">PlaceholderText:</TextBlock>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding #upDown.PlaceholderText}" VerticalAlignment="Center" Margin="2" />
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="2">Text:</TextBlock>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding #upDown.Text}" VerticalAlignment="Center" Margin="2" />
|
||||
@@ -81,23 +81,23 @@
|
||||
<NumericUpDown Name="upDown" Minimum="0" Maximum="10" Increment="0.5"
|
||||
NumberFormat="{Binding #CultureSelector.SelectedItem, Converter={x:Static pages:NumericUpDownPage.CultureConverter}}"
|
||||
VerticalAlignment="Center" Value="{Binding DecimalValue}"
|
||||
Watermark="Enter text" FormatString="{Binding SelectedFormat.Value}"/>
|
||||
PlaceholderText="Enter text" FormatString="{Binding SelectedFormat.Value}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="10">
|
||||
<Label Target="DoubleUpDown" FontSize="14" FontWeight="Bold" VerticalAlignment="Center">Usage of double NumericUpDown:</Label>
|
||||
<NumericUpDown Name="DoubleUpDown" Minimum="0" Maximum="10" Increment="0.5"
|
||||
VerticalAlignment="Center" Value="{Binding DoubleValue}"
|
||||
Watermark="Enter text" FormatString="{Binding SelectedFormat.Value}"/>
|
||||
PlaceholderText="Enter text" FormatString="{Binding SelectedFormat.Value}"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="10">
|
||||
<Label Target="ValidationUpDown" FontSize="14" FontWeight="Bold" VerticalAlignment="Center">NumericUpDown with Validation Errors:</Label>
|
||||
<NumericUpDown x:Name="ValidationUpDown" Minimum="0" Maximum="10" Increment="0.5"
|
||||
VerticalAlignment="Center"
|
||||
Watermark="Enter text" FormatString="{Binding SelectedFormat.Value}">
|
||||
PlaceholderText="Enter text" FormatString="{Binding SelectedFormat.Value}">
|
||||
<DataValidationErrors.Error>
|
||||
<sys:Exception />
|
||||
<sys:Exception />
|
||||
</DataValidationErrors.Error>
|
||||
</NumericUpDown>
|
||||
</StackPanel>
|
||||
@@ -110,10 +110,18 @@
|
||||
<converter:HexConverter></converter:HexConverter>
|
||||
</NumericUpDown.TextConverter>
|
||||
</NumericUpDown>
|
||||
|
||||
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="10">
|
||||
<Label FontSize="14" FontWeight="Bold" Target="PlaceholderForegroundUpDown"
|
||||
Content="Placeholder with custom foreground color:"/>
|
||||
<NumericUpDown x:Name="PlaceholderForegroundUpDown"
|
||||
PlaceholderText="Enter amount"
|
||||
PlaceholderForeground="Orange"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="10">
|
||||
<Label FontSize="14" FontWeight="Bold" Target="InnerContent"
|
||||
Content="Inner Contents"/>
|
||||
|
||||
@@ -17,34 +17,41 @@
|
||||
</Flyout>
|
||||
</TextBox.ContextFlyout>
|
||||
</TextBox>
|
||||
<TextBox Width="200" Watermark="ReadOnly" IsReadOnly="True" Text="This is read only"/>
|
||||
<TextBox Width="200" Watermark="Numeric with watermark" TextInputOptions.ContentType="Number" />
|
||||
<TextBox Width="200" PlaceholderText="ReadOnly" IsReadOnly="True" Text="This is read only"/>
|
||||
<TextBox Width="200" PlaceholderText="Numeric with placeholder" TextInputOptions.ContentType="Number" />
|
||||
<TextBox Width="200"
|
||||
Watermark="Floating Watermark"
|
||||
UseFloatingWatermark="True"
|
||||
PlaceholderText="Floating Placeholder"
|
||||
UseFloatingPlaceholder="True"
|
||||
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."/>
|
||||
<TextBox Width="200"
|
||||
PlaceholderText="Custom Placeholder Color"
|
||||
PlaceholderForeground="Red"/>
|
||||
<TextBox Width="200"
|
||||
PlaceholderText="Floating Placeholder Color"
|
||||
UseFloatingPlaceholder="True"
|
||||
PlaceholderForeground="Purple"/>
|
||||
<MaskedTextBox Width="200" ResetOnSpace="False" Mask="(LLL) 999-0000"/>
|
||||
|
||||
|
||||
<TextBox Width="200" Text="Validation Error">
|
||||
<DataValidationErrors.Error>
|
||||
<sys:Exception />
|
||||
<sys:Exception />
|
||||
</DataValidationErrors.Error>
|
||||
</TextBox>
|
||||
|
||||
<TextBox Width="200"
|
||||
Watermark="Password Box"
|
||||
PlaceholderText="Password Box"
|
||||
Classes="revealPasswordButton"
|
||||
TextInputOptions.ContentType="Password"
|
||||
UseFloatingWatermark="True"
|
||||
UseFloatingPlaceholder="True"
|
||||
PasswordChar="*"
|
||||
Text="Password" />
|
||||
<TextBox Width="200" Watermark="Suggestions are hidden" TextInputOptions.ShowSuggestions="False" />
|
||||
<TextBox Width="200" PlaceholderText="Suggestions are hidden" TextInputOptions.ShowSuggestions="False" />
|
||||
<TextBox Width="200" Text="Left aligned text" TextAlignment="Left" AcceptsTab="True" />
|
||||
<TextBox Width="200" Text="Center aligned text" TextAlignment="Center" />
|
||||
<TextBox Width="200" Text="Right aligned text" TextAlignment="Right" />
|
||||
<TextBox Width="200" Text="Custom selection brush"
|
||||
SelectionStart="5" SelectionEnd="22"
|
||||
SelectionBrush="Green" SelectionForegroundBrush="Yellow" ClearSelectionOnLostFocus="False"/>
|
||||
SelectionStart="5" SelectionEnd="22"
|
||||
SelectionBrush="Green" SelectionForegroundBrush="Yellow" ClearSelectionOnLostFocus="False"/>
|
||||
<TextBox Width="200" Text="Custom caret brush" CaretBrush="DarkOrange"/>
|
||||
</StackPanel>
|
||||
|
||||
@@ -54,11 +61,11 @@
|
||||
<TextBox AcceptsReturn="True" Width="200" Height="125"
|
||||
Text="Multiline TextBox with no TextWrapping.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est." />
|
||||
|
||||
<TextBox Classes="clearButton" Text="Clear Content" Width="200" FontWeight="Normal" FontStyle="Normal" Watermark="Watermark" FontFamily="avares://ControlCatalog/Assets/Fonts#Source Sans Pro"/>
|
||||
<TextBox Classes="clearButton" Text="Clear Content" Width="200" FontWeight="Normal" FontStyle="Normal" PlaceholderText="Placeholder" FontFamily="avares://ControlCatalog/Assets/Fonts#Source Sans Pro"/>
|
||||
<TextBox Text="IME small font" Width="200"
|
||||
FontFamily="Comic Sans MS"
|
||||
FontSize="10"
|
||||
Foreground="Red"/>
|
||||
FontFamily="Comic Sans MS"
|
||||
FontSize="10"
|
||||
Foreground="Red"/>
|
||||
<TextBox Text="IME large font" Width="200"
|
||||
FontFamily="Comic Sans MS"
|
||||
FontSize="22"
|
||||
@@ -67,9 +74,9 @@
|
||||
FontFamily="Comic Sans MS"
|
||||
InputMethod.IsInputMethodEnabled="False"
|
||||
Foreground="Red"/>
|
||||
<TextBox AcceptsReturn="True"
|
||||
TextWrapping="Wrap"
|
||||
Width="200"
|
||||
<TextBox AcceptsReturn="True"
|
||||
TextWrapping="Wrap"
|
||||
Width="200"
|
||||
Height="125"
|
||||
LineHeight="32"
|
||||
Text="Multiline TextBox with TextWrapping and increased LineHeight.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est." />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="ControlCatalog.Pages.ThemePage"
|
||||
<UserControl x:Class="ControlCatalog.Pages.ThemePage"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@@ -70,8 +70,8 @@
|
||||
</ComboBox>
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="Username:" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Column="0" Grid.Row="4" Text="Password:" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Watermark="Input here" HorizontalAlignment="Stretch" />
|
||||
<TextBox Grid.Column="1" Grid.Row="4" Watermark="Input here" HorizontalAlignment="Stretch" />
|
||||
<TextBox Grid.Column="1" Grid.Row="2" PlaceholderText="Input here" HorizontalAlignment="Stretch" />
|
||||
<TextBox Grid.Column="1" Grid.Row="4" PlaceholderText="Input here" HorizontalAlignment="Stretch" />
|
||||
<Button Grid.Column="1" Grid.Row="6" Content="Login" HorizontalAlignment="Stretch" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Generators.Sandbox.Controls"
|
||||
xmlns:vm="clr-namespace:Generators.Sandbox.ViewModels"
|
||||
@@ -17,8 +17,8 @@
|
||||
<controls:CustomTextBox Margin="0 10 0 0"
|
||||
x:Name="UserNameTextBox"
|
||||
Text="{Binding UserName}"
|
||||
Watermark="Please, enter user name..."
|
||||
UseFloatingWatermark="True" />
|
||||
PlaceholderText="Please, enter user name..."
|
||||
UseFloatingPlaceholder="True" />
|
||||
<TextBlock x:Name="UserNameValidation"
|
||||
Text="{Binding UserNameValidation}"
|
||||
Foreground="Green"
|
||||
@@ -26,8 +26,8 @@
|
||||
<TextBox Margin="0 10 0 0"
|
||||
x:Name="PasswordTextBox"
|
||||
Text="{Binding Password}"
|
||||
Watermark="Please, enter your password..."
|
||||
UseFloatingWatermark="True"
|
||||
PlaceholderText="Please, enter your password..."
|
||||
UseFloatingPlaceholder="True"
|
||||
PasswordChar="*" />
|
||||
<TextBlock x:Name="PasswordValidation"
|
||||
Text="{Binding PasswordValidation}"
|
||||
@@ -36,8 +36,8 @@
|
||||
<TextBox Margin="0 10 0 0"
|
||||
x:Name="ConfirmPasswordTextBox"
|
||||
Text="{Binding ConfirmPassword}"
|
||||
Watermark="Please, confirm the password..."
|
||||
UseFloatingWatermark="True"
|
||||
PlaceholderText="Please, confirm the password..."
|
||||
UseFloatingPlaceholder="True"
|
||||
PasswordChar="*" />
|
||||
<TextBlock x:Name="ConfirmPasswordValidation"
|
||||
Text="{Binding ConfirmPasswordValidation}"
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<Button Name="ScreenRefresh"
|
||||
Content="Refresh"
|
||||
Click="ScreenRefresh_Click"/>
|
||||
<TextBox Name="ScreenName" Watermark="DisplayName" UseFloatingWatermark="true" />
|
||||
<TextBox Name="ScreenHandle" Watermark="Handle" UseFloatingWatermark="true" />
|
||||
<TextBox Name="ScreenScaling" Watermark="Scaling" UseFloatingWatermark="true" />
|
||||
<TextBox Name="ScreenBounds" Watermark="Bounds" UseFloatingWatermark="true" />
|
||||
<TextBox Name="ScreenWorkArea" Watermark="WorkArea" UseFloatingWatermark="true" />
|
||||
<TextBox Name="ScreenOrientation" Watermark="Orientation" UseFloatingWatermark="true" />
|
||||
<TextBox Name="ScreenSameReference" Watermark="Is same reference" UseFloatingWatermark="true" />
|
||||
<TextBox Name="ScreenName" PlaceholderText="DisplayName" UseFloatingPlaceholder="true" />
|
||||
<TextBox Name="ScreenHandle" PlaceholderText="Handle" UseFloatingPlaceholder="true" />
|
||||
<TextBox Name="ScreenScaling" PlaceholderText="Scaling" UseFloatingPlaceholder="true" />
|
||||
<TextBox Name="ScreenBounds" PlaceholderText="Bounds" UseFloatingPlaceholder="true" />
|
||||
<TextBox Name="ScreenWorkArea" PlaceholderText="WorkArea" UseFloatingPlaceholder="true" />
|
||||
<TextBox Name="ScreenOrientation" PlaceholderText="Orientation" UseFloatingPlaceholder="true" />
|
||||
<TextBox Name="ScreenSameReference" PlaceholderText="Is same reference" UseFloatingPlaceholder="true" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<CheckBox Name="WindowPreferSystemChrome" Content="Prefer SystemChrome" />
|
||||
<CheckBox Name="WindowMacThickSystemChrome" Content="Mac Thick SystemChrome" />
|
||||
<CheckBox Name="WindowShowTitleAreaControl" Content="Show Title Area Control" />
|
||||
<TextBox Name="WindowTitleBarHeightHint" Text="-1" Watermark="In dips" />
|
||||
<TextBox Name="WindowTitleBarHeightHint" Text="-1" PlaceholderText="In dips" />
|
||||
<Button Name="ApplyWindowDecorations"
|
||||
Content="Apply decorations on this Window"
|
||||
Click="ApplyWindowDecorations_Click"/>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
x:Class="IntegrationTestApp.Pages.WindowPage">
|
||||
<Grid ColumnDefinitions="*,8,*">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBox Name="ShowWindowSize" Watermark="Window Size"/>
|
||||
<TextBox Name="ShowWindowSize" PlaceholderText="Window Size"/>
|
||||
<ComboBox Name="ShowWindowMode" SelectedIndex="0">
|
||||
<ComboBoxItem>NonOwned</ComboBoxItem>
|
||||
<ComboBoxItem>Owned</ComboBoxItem>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<Label Margin="5"
|
||||
Foreground="Red"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalContentAlignment="Right">View Bounds</Label>
|
||||
HorizontalContentAlignment="Right">View Bounds</Label>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border BorderBrush="LimeGreen"
|
||||
@@ -47,7 +47,7 @@
|
||||
<CheckBox IsChecked="{Binding UseSafeArea}" IsEnabled="{Binding !AutoSafeAreaPadding}">Use Safe Area</CheckBox>
|
||||
<CheckBox IsChecked="{Binding AutoSafeAreaPadding}">Automatic Paddings</CheckBox>
|
||||
<CheckBox IsChecked="{Binding HideSystemBars}">Hide System Bars</CheckBox>
|
||||
<TextBox Width="200" Watermark="Tap to Show Keyboard"/>
|
||||
<TextBox Width="200" PlaceholderText="Tap to Show Keyboard"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
x:DataType="local:MainView">
|
||||
<StackPanel Margin="100 50" Spacing="50">
|
||||
<TextBlock Text="Login" Foreground="White" />
|
||||
<TextBox TextInputOptions.Multiline="True" AcceptsReturn="True" Watermark="Text" Height="200" TextWrapping="Wrap"/>
|
||||
<TextBox Watermark="Username" TextInputOptions.ContentType="Email" TextInputOptions.ReturnKeyType="Done" />
|
||||
<TextBox Watermark="Password" PasswordChar="*" TextInputOptions.ContentType="Password" />
|
||||
<TextBox Watermark="Pin" PasswordChar="*" TextInputOptions.ContentType="Digits" TextInputOptions.ReturnKeyType="Next" />
|
||||
<TextBox TextInputOptions.Multiline="True" AcceptsReturn="True" PlaceholderText="Text" Height="200" TextWrapping="Wrap"/>
|
||||
<TextBox PlaceholderText="Username" TextInputOptions.ContentType="Email" TextInputOptions.ReturnKeyType="Done" />
|
||||
<TextBox PlaceholderText="Password" PasswordChar="*" TextInputOptions.ContentType="Password" />
|
||||
<TextBox PlaceholderText="Pin" PasswordChar="*" TextInputOptions.ContentType="Digits" TextInputOptions.ReturnKeyType="Next" />
|
||||
<Button Content="Login" Command="{Binding ButtonCommand}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (c) Copyright Microsoft Corporation.
|
||||
// (c) Copyright Microsoft Corporation.
|
||||
// This source is subject to the Microsoft Public License (Ms-PL).
|
||||
// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
|
||||
// All other rights reserved.
|
||||
@@ -24,8 +24,37 @@ namespace Avalonia.Controls
|
||||
defaultValue: 0,
|
||||
defaultBindingMode: BindingMode.TwoWay));
|
||||
|
||||
public static readonly StyledProperty<string?> WatermarkProperty =
|
||||
TextBox.WatermarkProperty.AddOwner<AutoCompleteBox>();
|
||||
/// <summary>
|
||||
/// Defines the <see cref="PlaceholderText"/> property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013",
|
||||
Justification = "We keep WatermarkProperty for backward compatibility.")]
|
||||
public static readonly StyledProperty<string?> PlaceholderTextProperty =
|
||||
TextBox.PlaceholderTextProperty.AddOwner<AutoCompleteBox>();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="Watermark"/> property.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderTextProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<string?> WatermarkProperty = PlaceholderTextProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="PlaceholderForeground"/> property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013",
|
||||
Justification = "We keep WatermarkForegroundProperty for backward compatibility.")]
|
||||
public static readonly StyledProperty<Media.IBrush?> PlaceholderForegroundProperty =
|
||||
TextBox.PlaceholderForegroundProperty.AddOwner<AutoCompleteBox>();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="WatermarkForeground"/> property.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderForegroundProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<Media.IBrush?> WatermarkForegroundProperty = PlaceholderForegroundProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="MinimumPrefixLength" /> property.
|
||||
@@ -406,10 +435,46 @@ namespace Avalonia.Controls
|
||||
set => SetValue(FilterModeProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the placeholder or descriptive text that is displayed even if the text is not yet set.
|
||||
/// </summary>
|
||||
public string? PlaceholderText
|
||||
{
|
||||
get => GetValue(PlaceholderTextProperty);
|
||||
set => SetValue(PlaceholderTextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the placeholder or descriptive text that is displayed even if the text is not yet set.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderText instead.", false)]
|
||||
public string? Watermark
|
||||
{
|
||||
get => GetValue(WatermarkProperty);
|
||||
set => SetValue(WatermarkProperty, value);
|
||||
get => PlaceholderText;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderText = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brush used for the foreground color of the placeholder text.
|
||||
/// </summary>
|
||||
public Media.IBrush? PlaceholderForeground
|
||||
{
|
||||
get => GetValue(PlaceholderForegroundProperty);
|
||||
set => SetValue(PlaceholderForegroundProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brush used for the foreground color of the placeholder text.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderForeground instead.", false)]
|
||||
public Media.IBrush? WatermarkForeground
|
||||
{
|
||||
get => PlaceholderForeground;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderForeground = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Layout;
|
||||
@@ -53,7 +53,7 @@ namespace Avalonia.Controls
|
||||
public static readonly StyledProperty<DateTime?> SelectedDateProperty =
|
||||
AvaloniaProperty.Register<CalendarDatePicker, DateTime?>(
|
||||
nameof(SelectedDate),
|
||||
enableDataValidation: true,
|
||||
enableDataValidation: true,
|
||||
defaultBindingMode:BindingMode.TwoWay);
|
||||
|
||||
/// <summary>
|
||||
@@ -80,17 +80,53 @@ namespace Avalonia.Controls
|
||||
public static readonly StyledProperty<string?> TextProperty =
|
||||
AvaloniaProperty.Register<CalendarDatePicker, string?>(nameof(Text));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="PlaceholderText"/> property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013",
|
||||
Justification = "We keep WatermarkProperty for backward compatibility.")]
|
||||
public static readonly StyledProperty<string?> PlaceholderTextProperty =
|
||||
TextBox.PlaceholderTextProperty.AddOwner<CalendarDatePicker>();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="Watermark"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<string?> WatermarkProperty =
|
||||
TextBox.WatermarkProperty.AddOwner<CalendarDatePicker>();
|
||||
[Obsolete("Use PlaceholderTextProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<string?> WatermarkProperty = PlaceholderTextProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="UseFloatingPlaceholder"/> property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013",
|
||||
Justification = "We keep UseFloatingWatermarkProperty for backward compatibility.")]
|
||||
public static readonly StyledProperty<bool> UseFloatingPlaceholderProperty =
|
||||
TextBox.UseFloatingPlaceholderProperty.AddOwner<CalendarDatePicker>();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="UseFloatingWatermark"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty =
|
||||
TextBox.UseFloatingWatermarkProperty.AddOwner<CalendarDatePicker>();
|
||||
[Obsolete("Use UseFloatingPlaceholderProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty = UseFloatingPlaceholderProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="PlaceholderForeground"/> property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013",
|
||||
Justification = "We keep WatermarkForegroundProperty for backward compatibility.")]
|
||||
public static readonly StyledProperty<Media.IBrush?> PlaceholderForegroundProperty =
|
||||
TextBox.PlaceholderForegroundProperty.AddOwner<CalendarDatePicker>();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="WatermarkForeground"/> property.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderForegroundProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<Media.IBrush?> WatermarkForegroundProperty = PlaceholderForegroundProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="HorizontalContentAlignment"/> property.
|
||||
@@ -130,7 +166,7 @@ namespace Avalonia.Controls
|
||||
get => GetValue(DisplayDateProperty);
|
||||
set => SetValue(DisplayDateProperty, value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the first date to be displayed.
|
||||
/// </summary>
|
||||
@@ -254,18 +290,55 @@ namespace Avalonia.Controls
|
||||
set => SetValue(TextProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TextBox.PlaceholderText"/>
|
||||
public string? PlaceholderText
|
||||
{
|
||||
get => GetValue(PlaceholderTextProperty);
|
||||
set => SetValue(PlaceholderTextProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TextBox.Watermark"/>
|
||||
[Obsolete("Use PlaceholderText instead.", false)]
|
||||
public string? Watermark
|
||||
{
|
||||
get => GetValue(WatermarkProperty);
|
||||
set => SetValue(WatermarkProperty, value);
|
||||
get => PlaceholderText;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderText = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TextBox.UseFloatingPlaceholder"/>
|
||||
public bool UseFloatingPlaceholder
|
||||
{
|
||||
get => GetValue(UseFloatingPlaceholderProperty);
|
||||
set => SetValue(UseFloatingPlaceholderProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TextBox.UseFloatingWatermark"/>
|
||||
[Obsolete("Use UseFloatingPlaceholder instead.", false)]
|
||||
public bool UseFloatingWatermark
|
||||
{
|
||||
get => GetValue(UseFloatingWatermarkProperty);
|
||||
set => SetValue(UseFloatingWatermarkProperty, value);
|
||||
get => UseFloatingPlaceholder;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => UseFloatingPlaceholder = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TextBox.PlaceholderForeground"/>
|
||||
public Media.IBrush? PlaceholderForeground
|
||||
{
|
||||
get => GetValue(PlaceholderForegroundProperty);
|
||||
set => SetValue(PlaceholderForegroundProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TextBox.WatermarkForeground"/>
|
||||
[Obsolete("Use PlaceholderForeground instead.", false)]
|
||||
public Media.IBrush? WatermarkForeground
|
||||
{
|
||||
get => PlaceholderForeground;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderForeground = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -570,7 +570,7 @@ namespace Avalonia.Controls
|
||||
|
||||
private void Calendar_PointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
if (e.InitialPressMouseButton == MouseButton.Left)
|
||||
{
|
||||
e.Handled = true;
|
||||
@@ -779,7 +779,7 @@ namespace Avalonia.Controls
|
||||
return true;
|
||||
}
|
||||
case Key.Down:
|
||||
{
|
||||
{
|
||||
if ((e.KeyModifiers & KeyModifiers.Control) == KeyModifiers.Control)
|
||||
{
|
||||
TogglePopUp();
|
||||
@@ -816,7 +816,7 @@ namespace Avalonia.Controls
|
||||
}
|
||||
}
|
||||
DateTime? d = SetTextBoxValue(s);
|
||||
|
||||
|
||||
if (SelectedDate != d)
|
||||
{
|
||||
SetCurrentValue(SelectedDateProperty, d);
|
||||
@@ -880,39 +880,39 @@ namespace Avalonia.Controls
|
||||
if (_textBox != null)
|
||||
{
|
||||
SetCurrentValue(TextProperty, String.Empty);
|
||||
|
||||
if (string.IsNullOrEmpty(Watermark) && !UseFloatingWatermark)
|
||||
|
||||
if (string.IsNullOrEmpty(PlaceholderText) && !UseFloatingPlaceholder)
|
||||
{
|
||||
DateTimeFormatInfo dtfi = DateTimeHelper.GetCurrentDateFormat();
|
||||
_defaultText = string.Empty;
|
||||
var watermarkFormat = "<{0}>";
|
||||
string watermarkText;
|
||||
var placeholderFormat = "<{0}>";
|
||||
string placeholderText;
|
||||
|
||||
switch (SelectedDateFormat)
|
||||
{
|
||||
case CalendarDatePickerFormat.Custom:
|
||||
{
|
||||
watermarkText = string.Format(CultureInfo.CurrentCulture, watermarkFormat, CustomDateFormatString);
|
||||
placeholderText = string.Format(CultureInfo.CurrentCulture, placeholderFormat, CustomDateFormatString);
|
||||
break;
|
||||
}
|
||||
case CalendarDatePickerFormat.Long:
|
||||
{
|
||||
watermarkText = string.Format(CultureInfo.CurrentCulture, watermarkFormat, dtfi.LongDatePattern.ToString());
|
||||
placeholderText = string.Format(CultureInfo.CurrentCulture, placeholderFormat, dtfi.LongDatePattern.ToString());
|
||||
break;
|
||||
}
|
||||
case CalendarDatePickerFormat.Short:
|
||||
default:
|
||||
{
|
||||
watermarkText = string.Format(CultureInfo.CurrentCulture, watermarkFormat, dtfi.ShortDatePattern.ToString());
|
||||
placeholderText = string.Format(CultureInfo.CurrentCulture, placeholderFormat, dtfi.ShortDatePattern.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_textBox.Watermark = watermarkText;
|
||||
_textBox.PlaceholderText = placeholderText;
|
||||
}
|
||||
else
|
||||
{
|
||||
_textBox.ClearValue(TextBox.WatermarkProperty);
|
||||
_textBox.ClearValue(TextBox.PlaceholderTextProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -108,11 +108,35 @@ namespace Avalonia.Controls
|
||||
AvaloniaProperty.Register<NumericUpDown, decimal?>(nameof(Value), coerce: (s,v) => ((NumericUpDown)s).OnCoerceValue(v),
|
||||
defaultBindingMode: BindingMode.TwoWay, enableDataValidation: true);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="PlaceholderText"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<string?> PlaceholderTextProperty =
|
||||
AvaloniaProperty.Register<NumericUpDown, string?>(nameof(PlaceholderText));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="Watermark"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<string?> WatermarkProperty =
|
||||
AvaloniaProperty.Register<NumericUpDown, string?>(nameof(Watermark));
|
||||
[Obsolete("Use PlaceholderTextProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<string?> WatermarkProperty = PlaceholderTextProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="PlaceholderForeground"/> property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013",
|
||||
Justification = "We keep WatermarkForegroundProperty for backward compatibility.")]
|
||||
public static readonly StyledProperty<Media.IBrush?> PlaceholderForegroundProperty =
|
||||
TextBox.PlaceholderForegroundProperty.AddOwner<NumericUpDown>();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="WatermarkForeground"/> property.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderForegroundProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<Media.IBrush?> WatermarkForegroundProperty = PlaceholderForegroundProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="HorizontalContentAlignment"/> property.
|
||||
@@ -253,7 +277,7 @@ namespace Avalonia.Controls
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parsing style (AllowLeadingWhite, Float, AllowHexSpecifier, ...). By default, Any.
|
||||
/// Note that Hex style does not work with decimal.
|
||||
/// Note that Hex style does not work with decimal.
|
||||
/// For hexadecimal display, use <see cref="TextConverter"/>.
|
||||
/// </summary>
|
||||
public NumberStyles ParsingNumberStyle
|
||||
@@ -273,7 +297,7 @@ namespace Avalonia.Controls
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom bidirectional Text-Value converter.
|
||||
/// Non-null converter overrides <see cref="ParsingNumberStyle"/>, providing finer control over
|
||||
/// Non-null converter overrides <see cref="ParsingNumberStyle"/>, providing finer control over
|
||||
/// string representation of the underlying value.
|
||||
/// </summary>
|
||||
public IValueConverter? TextConverter
|
||||
@@ -292,12 +316,45 @@ namespace Avalonia.Controls
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the object to use as a watermark if the <see cref="Value"/> is null.
|
||||
/// Gets or sets the object to use as a placeholder if the <see cref="Value"/> is null.
|
||||
/// </summary>
|
||||
public string? PlaceholderText
|
||||
{
|
||||
get => GetValue(PlaceholderTextProperty);
|
||||
set => SetValue(PlaceholderTextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the object to use as a placeholder if the <see cref="Value"/> is null.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderText instead.", false)]
|
||||
public string? Watermark
|
||||
{
|
||||
get => GetValue(WatermarkProperty);
|
||||
set => SetValue(WatermarkProperty, value);
|
||||
get => PlaceholderText;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderText = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brush used for the foreground color of the placeholder text.
|
||||
/// </summary>
|
||||
public Media.IBrush? PlaceholderForeground
|
||||
{
|
||||
get => GetValue(PlaceholderForegroundProperty);
|
||||
set => SetValue(PlaceholderForegroundProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brush used for the foreground color of the placeholder text.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderForeground instead.", false)]
|
||||
public Media.IBrush? WatermarkForeground
|
||||
{
|
||||
get => PlaceholderForeground;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderForeground = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -700,8 +757,8 @@ namespace Avalonia.Controls
|
||||
}
|
||||
else
|
||||
{
|
||||
// if Minimum is set we set value to Minimum on Increment.
|
||||
// otherwise we set value to 0. It ill be clamped to be between Minimum and Maximum later, so we don't need to do it here.
|
||||
// if Minimum is set we set value to Minimum on Increment.
|
||||
// otherwise we set value to 0. It ill be clamped to be between Minimum and Maximum later, so we don't need to do it here.
|
||||
result = IsSet(MinimumProperty) ? Minimum : 0;
|
||||
}
|
||||
|
||||
@@ -721,8 +778,8 @@ namespace Avalonia.Controls
|
||||
}
|
||||
else
|
||||
{
|
||||
// if Maximum is set we set value to Maximum on decrement.
|
||||
// otherwise we set value to 0. It ill be clamped to be between Minimum and Maximum later, so we don't need to do it here.
|
||||
// if Maximum is set we set value to Maximum on decrement.
|
||||
// otherwise we set value to 0. It ill be clamped to be between Minimum and Maximum later, so we don't need to do it here.
|
||||
result = IsSet(MaximumProperty) ? Maximum : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +48,13 @@ namespace Avalonia.Controls
|
||||
/// <summary>
|
||||
/// Defines the <see cref="IsInactiveSelectionHighlightEnabled"/> property
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> IsInactiveSelectionHighlightEnabledProperty =
|
||||
public static readonly StyledProperty<bool> IsInactiveSelectionHighlightEnabledProperty =
|
||||
AvaloniaProperty.Register<TextBox, bool>(nameof(IsInactiveSelectionHighlightEnabled), defaultValue: true);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="ClearSelectionOnLostFocus"/> property
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> ClearSelectionOnLostFocusProperty =
|
||||
public static readonly StyledProperty<bool> ClearSelectionOnLostFocusProperty =
|
||||
AvaloniaProperty.Register<TextBox, bool>(nameof(ClearSelectionOnLostFocus), defaultValue: true);
|
||||
|
||||
/// <summary>
|
||||
@@ -181,16 +181,46 @@ namespace Avalonia.Controls
|
||||
TextBlock.LineHeightProperty.AddOwner<TextBox>(new(defaultValue: double.NaN));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="Watermark"/> property
|
||||
/// Defines the <see cref="PlaceholderText"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<string?> WatermarkProperty =
|
||||
AvaloniaProperty.Register<TextBox, string?>(nameof(Watermark));
|
||||
public static readonly StyledProperty<string?> PlaceholderTextProperty =
|
||||
AvaloniaProperty.Register<TextBox, string?>(nameof(PlaceholderText));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="UseFloatingWatermark"/> property
|
||||
/// Defines the <see cref="Watermark"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty =
|
||||
AvaloniaProperty.Register<TextBox, bool>(nameof(UseFloatingWatermark));
|
||||
[Obsolete("Use PlaceholderTextProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<string?> WatermarkProperty = PlaceholderTextProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="UseFloatingPlaceholder"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> UseFloatingPlaceholderProperty =
|
||||
AvaloniaProperty.Register<TextBox, bool>(nameof(UseFloatingPlaceholder));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="UseFloatingWatermark"/> property.
|
||||
/// </summary>
|
||||
[Obsolete("Use UseFloatingPlaceholderProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty = UseFloatingPlaceholderProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="PlaceholderForeground"/> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<IBrush?> PlaceholderForegroundProperty =
|
||||
AvaloniaProperty.Register<TextBox, IBrush?>(nameof(PlaceholderForeground));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="WatermarkForeground"/> property.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderForegroundProperty instead.", false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
|
||||
Justification = "Obsolete property alias for backward compatibility.")]
|
||||
public static readonly StyledProperty<IBrush?> WatermarkForegroundProperty = PlaceholderForegroundProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="NewLine"/> property
|
||||
@@ -394,8 +424,8 @@ namespace Avalonia.Controls
|
||||
/// </summary>
|
||||
public bool ClearSelectionOnLostFocus
|
||||
{
|
||||
get=> GetValue(ClearSelectionOnLostFocusProperty);
|
||||
set=> SetValue(ClearSelectionOnLostFocusProperty, value);
|
||||
get => GetValue(ClearSelectionOnLostFocusProperty);
|
||||
set => SetValue(ClearSelectionOnLostFocusProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -408,7 +438,7 @@ namespace Avalonia.Controls
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value that determins whether the TextBox allows and displays tabs
|
||||
/// Gets or sets a value that determines whether the TextBox allows and displays tabs
|
||||
/// </summary>
|
||||
public bool AcceptsTab
|
||||
{
|
||||
@@ -516,7 +546,7 @@ namespace Avalonia.Controls
|
||||
/// Gets or sets the end position of the text selected in the TextBox
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When the SelectionEnd is equal to <see cref="SelectionStart"/>, there is no
|
||||
/// When the SelectionEnd is equal to <see cref="SelectionStart"/>, there is no
|
||||
/// selected text and it marks the caret position
|
||||
/// </remarks>
|
||||
public int SelectionEnd
|
||||
@@ -665,20 +695,67 @@ namespace Avalonia.Controls
|
||||
/// Gets or sets the placeholder or descriptive text that is displayed even if the <see cref="Text"/>
|
||||
/// property is not yet set.
|
||||
/// </summary>
|
||||
public string? Watermark
|
||||
public string? PlaceholderText
|
||||
{
|
||||
get => GetValue(WatermarkProperty);
|
||||
set => SetValue(WatermarkProperty, value);
|
||||
get => GetValue(PlaceholderTextProperty);
|
||||
set => SetValue(PlaceholderTextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the <see cref="Watermark"/> will still be shown above the
|
||||
/// Gets or sets the placeholder or descriptive text that is displayed even if the <see cref="Text"/>
|
||||
/// property is not yet set.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderText instead.", false)]
|
||||
public string? Watermark
|
||||
{
|
||||
get => PlaceholderText;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderText = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the <see cref="PlaceholderText"/> will still be shown above the
|
||||
/// <see cref="Text"/> even after a text value is set.
|
||||
/// </summary>
|
||||
public bool UseFloatingPlaceholder
|
||||
{
|
||||
get => GetValue(UseFloatingPlaceholderProperty);
|
||||
set => SetValue(UseFloatingPlaceholderProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the <see cref="PlaceholderText"/> will still be shown above the
|
||||
/// <see cref="Text"/> even after a text value is set.
|
||||
/// </summary>
|
||||
[Obsolete("Use UseFloatingPlaceholder instead.", false)]
|
||||
public bool UseFloatingWatermark
|
||||
{
|
||||
get => GetValue(UseFloatingWatermarkProperty);
|
||||
set => SetValue(UseFloatingWatermarkProperty, value);
|
||||
get => UseFloatingPlaceholder;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => UseFloatingPlaceholder = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brush used for the foreground color of the placeholder text.
|
||||
/// </summary>
|
||||
public IBrush? PlaceholderForeground
|
||||
{
|
||||
get => GetValue(PlaceholderForegroundProperty);
|
||||
set => SetValue(PlaceholderForegroundProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brush used for the foreground color of the placeholder text.
|
||||
/// </summary>
|
||||
[Obsolete("Use PlaceholderForeground instead.", false)]
|
||||
public IBrush? WatermarkForeground
|
||||
{
|
||||
get => PlaceholderForeground;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
|
||||
Justification = "Obsolete property setter for backward compatibility.")]
|
||||
set => PlaceholderForeground = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1018,7 +1095,7 @@ namespace Avalonia.Controls
|
||||
if(_presenter != null)
|
||||
{
|
||||
_presenter.ShowSelectionHighlight = true;
|
||||
}
|
||||
}
|
||||
|
||||
// when navigating to a textbox via the tab key, select all text if
|
||||
// 1) this textbox is *not* a multiline textbox
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:generic="using:System.Collections.Generic"
|
||||
x:ClassModifier="internal">
|
||||
@@ -20,7 +20,7 @@
|
||||
</AutoCompleteBox>
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
|
||||
|
||||
<ControlTheme x:Key="{x:Type AutoCompleteBox}" TargetType="AutoCompleteBox">
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
|
||||
@@ -34,7 +34,8 @@
|
||||
<ControlTemplate>
|
||||
<Grid Name="PART_LayoutRoot">
|
||||
<TextBox Name="PART_TextBox"
|
||||
Watermark="{TemplateBinding Watermark}"
|
||||
PlaceholderText="{TemplateBinding PlaceholderText}"
|
||||
PlaceholderForeground="{TemplateBinding PlaceholderForeground}"
|
||||
Width="{TemplateBinding Width}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Background="{TemplateBinding Background}"
|
||||
@@ -50,9 +51,9 @@
|
||||
InnerLeftContent="{TemplateBinding InnerLeftContent}"
|
||||
InnerRightContent="{TemplateBinding InnerRightContent}"
|
||||
/>
|
||||
<Popup Name="PART_Popup"
|
||||
<Popup Name="PART_Popup"
|
||||
WindowManagerAddShadowHint="False"
|
||||
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
IsLightDismissEnabled="True"
|
||||
PlacementTarget="{TemplateBinding}">
|
||||
@@ -74,5 +75,5 @@
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="using:System"
|
||||
x:ClassModifier="internal">
|
||||
@@ -92,8 +92,9 @@
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Watermark="{TemplateBinding Watermark}"
|
||||
UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}"
|
||||
PlaceholderText="{TemplateBinding PlaceholderText}"
|
||||
PlaceholderForeground="{TemplateBinding PlaceholderForeground}"
|
||||
UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
@@ -112,7 +113,7 @@
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ TextBlock#PART_Watermark, ^ TextBlock#PART_FloatingWatermark">
|
||||
<Style Selector="^ /template/ TextBlock#PART_Placeholder, ^ TextBlock#PART_FloatingPlaceholder">
|
||||
<Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerTextForegroundDisabled}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="using:System"
|
||||
x:ClassModifier="internal">
|
||||
@@ -16,7 +16,7 @@
|
||||
<ComboBoxItem>Item 1</ComboBoxItem>
|
||||
<ComboBoxItem>Item 2</ComboBoxItem>
|
||||
</ComboBox>
|
||||
|
||||
|
||||
<ComboBox PlaceholderText="Error">
|
||||
<DataValidationErrors.Error>
|
||||
<sys:Exception>
|
||||
@@ -126,7 +126,7 @@
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Background="Transparent"
|
||||
Text="{TemplateBinding Text, Mode=TwoWay}"
|
||||
Watermark="{TemplateBinding PlaceholderText}"
|
||||
PlaceholderText="{TemplateBinding PlaceholderText}"
|
||||
BorderThickness="0"
|
||||
IsVisible="{TemplateBinding IsEditable}">
|
||||
<TextBox.Resources>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:dialogs="using:Avalonia.Dialogs"
|
||||
xmlns:internal="using:Avalonia.Dialogs.Internal"
|
||||
@@ -166,7 +166,7 @@
|
||||
<Path Data="M 0 7 L 7 0 L 14 7 M 7 0 L 7 16" Stroke="{CompiledBinding $parent[Button].Foreground}" StrokeThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,-1"/>
|
||||
</Button>
|
||||
<Button Command="{Binding Refresh}" DockPanel.Dock="Right" Margin="8,0,0,0">
|
||||
<Path Data="M18.62 3.32c.39 0 .7.29.76.66v3c0 .39-.28.7-.66.76h-3a.77.77 0 0 1-.1-1.52h1.08a7.42 7.42 0 1 0 2.65 4.37.77.77 0 1 1 1.5-.3 8.94 8.94 0 1 1-3-5.12V4.09c0-.43.35-.77.77-.77Z"
|
||||
<Path Data="M18.62 3.32c.39 0 .7.29.76.66v3c0 .39-.28.7-.66.76h-3a.77.77 0 0 1-.1-1.52h1.08a7.42 7.42 0 1 0 2.65 4.37.77.77 0 1 1 1.5-.3 8.94 8.94 0 1 1-3-5.12V4.09c0-.43.35-.77.77-.77Z"
|
||||
Fill="{CompiledBinding $parent[Button].Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="-2,-4,0,0"/>
|
||||
</Button>
|
||||
<TextBox x:Name="Location" Text="{Binding Location}">
|
||||
@@ -184,7 +184,7 @@
|
||||
IsVisible="{Binding ShowFilters}"
|
||||
ItemsSource="{Binding Filters}"
|
||||
SelectedItem="{Binding SelectedFilter}" />
|
||||
<TextBox Text="{Binding FileName}" Watermark="{DynamicResource StringManagedFileChooserFileNameWatermark}" IsVisible="{Binding !SelectingFolder}" />
|
||||
<TextBox Text="{Binding FileName}" PlaceholderText="{DynamicResource StringManagedFileChooserFileNamePlaceholder}" IsVisible="{Binding !SelectingFolder}" />
|
||||
</DockPanel>
|
||||
<CheckBox IsChecked="{Binding ShowHiddenFiles}" Content="{DynamicResource StringManagedFileChooserShowHiddenFilesText}" DockPanel.Dock="Left"/>
|
||||
<UniformGrid x:Name="Finalize" HorizontalAlignment="Right" Rows="1">
|
||||
@@ -344,7 +344,7 @@
|
||||
<Setter Property="Margin" Value="4,0,0,0"/>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
|
||||
<ControlTheme x:Key="{x:Type dialogs:ManagedFileChooserOverwritePrompt}" TargetType="dialogs:ManagedFileChooserOverwritePrompt">
|
||||
<Setter Property="MinWidth" Value="270" />
|
||||
<Setter Property="MaxWidth" Value="400" />
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
|
||||
x:ClassModifier="internal">
|
||||
<Design.PreviewWith>
|
||||
<Border Padding="20">
|
||||
<StackPanel Spacing="20">
|
||||
<NumericUpDown Minimum="0"
|
||||
Maximum="10"
|
||||
Increment="0.5"
|
||||
PlaceholderText="Enter text" />
|
||||
<NumericUpDown Minimum="0"
|
||||
Maximum="10"
|
||||
Increment="0.5"
|
||||
Watermark="Enter text" />
|
||||
<NumericUpDown Minimum="0"
|
||||
Maximum="10"
|
||||
Increment="0.5"
|
||||
VerticalContentAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
ButtonSpinnerLocation="Left"
|
||||
Watermark="Enter text" />
|
||||
Maximum="10"
|
||||
Increment="0.5"
|
||||
VerticalContentAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
ButtonSpinnerLocation="Left"
|
||||
PlaceholderText="Enter text" />
|
||||
<NumericUpDown ButtonSpinnerLocation="Left">
|
||||
<NumericUpDown.InnerLeftContent>
|
||||
<TextBlock Text="m"
|
||||
@@ -81,7 +81,8 @@
|
||||
Padding="{TemplateBinding Padding}"
|
||||
MinWidth="0"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Watermark="{TemplateBinding Watermark}"
|
||||
PlaceholderText="{TemplateBinding PlaceholderText}"
|
||||
PlaceholderForeground="{TemplateBinding PlaceholderForeground}"
|
||||
IsReadOnly="{TemplateBinding IsReadOnly}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<TextBox Classes="clearButton">Clear</TextBox>
|
||||
<TextBox PasswordChar="*" Classes="revealPasswordButton">Reveal Password</TextBox>
|
||||
<TextBox PasswordChar="*" Classes="revealPasswordButton" RevealPassword="True">Password Revealed</TextBox>
|
||||
<TextBox Watermark="Watermark"/>
|
||||
<TextBox Watermark="Floating Watermark" UseFloatingWatermark="True"/>
|
||||
<TextBox Watermark="Floating Watermark" UseFloatingWatermark="True">Content</TextBox>
|
||||
<TextBox PlaceholderText="Placeholder"/>
|
||||
<TextBox PlaceholderText="Floating Placeholder" UseFloatingPlaceholder="True"/>
|
||||
<TextBox PlaceholderText="Floating Placeholder" UseFloatingPlaceholder="True">Content</TextBox>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
@@ -20,7 +20,7 @@
|
||||
<StreamGeometry x:Key="TextBoxClearButtonData">M 11.416016,10 20,1.4160156 18.583984,0 10,8.5839846 1.4160156,0 0,1.4160156 8.5839844,10 0,18.583985 1.4160156,20 10,11.416015 18.583984,20 20,18.583985 Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="PasswordBoxRevealButtonData">m10.051 7.0032c2.215 0 4.0105 1.7901 4.0105 3.9984s-1.7956 3.9984-4.0105 3.9984c-2.215 0-4.0105-1.7901-4.0105-3.9984s1.7956-3.9984 4.0105-3.9984zm0 1.4994c-1.3844 0-2.5066 1.1188-2.5066 2.499s1.1222 2.499 2.5066 2.499 2.5066-1.1188 2.5066-2.499-1.1222-2.499-2.5066-2.499zm0-5.0026c4.6257 0 8.6188 3.1487 9.7267 7.5613 0.10085 0.40165-0.14399 0.80877-0.54686 0.90931-0.40288 0.10054-0.81122-0.14355-0.91208-0.54521-0.94136-3.7492-4.3361-6.4261-8.2678-6.4261-3.9334 0-7.3292 2.6792-8.2689 6.4306-0.10063 0.40171-0.50884 0.64603-0.91177 0.54571s-0.648-0.5073-0.54737-0.90901c1.106-4.4152 5.1003-7.5667 9.728-7.5667z</StreamGeometry>
|
||||
<StreamGeometry x:Key="PasswordBoxHideButtonData">m0.21967 0.21965c-0.26627 0.26627-0.29047 0.68293-0.07262 0.97654l0.07262 0.08412 4.0346 4.0346c-1.922 1.3495-3.3585 3.365-3.9554 5.7495-0.10058 0.4018 0.14362 0.8091 0.54543 0.9097 0.40182 0.1005 0.80909-0.1436 0.90968-0.5455 0.52947-2.1151 1.8371-3.8891 3.5802-5.0341l1.8096 1.8098c-0.70751 0.7215-1.1438 1.71-1.1438 2.8003 0 2.2092 1.7909 4 4 4 1.0904 0 2.0788-0.4363 2.8004-1.1438l5.9193 5.9195c0.2929 0.2929 0.7677 0.2929 1.0606 0 0.2663-0.2662 0.2905-0.6829 0.0726-0.9765l-0.0726-0.0841-6.1135-6.1142 0.0012-0.0015-1.2001-1.1979-2.8699-2.8693 2e-3 -8e-4 -2.8812-2.8782 0.0012-0.0018-1.1333-1.1305-4.3064-4.3058c-0.29289-0.29289-0.76777-0.29289-1.0607 0zm7.9844 9.0458 3.5351 3.5351c-0.45 0.4358-1.0633 0.704-1.7392 0.704-1.3807 0-2.5-1.1193-2.5-2.5 0-0.6759 0.26824-1.2892 0.7041-1.7391zm1.7959-5.7655c-1.0003 0-1.9709 0.14807-2.8889 0.425l1.237 1.2362c0.5358-0.10587 1.0883-0.16119 1.6519-0.16119 3.9231 0 7.3099 2.6803 8.2471 6.4332 0.1004 0.4018 0.5075 0.6462 0.9094 0.5459 0.4019-0.1004 0.6463-0.5075 0.5459-0.9094-1.103-4.417-5.0869-7.5697-9.7024-7.5697zm0.1947 3.5093 3.8013 3.8007c-0.1018-2.0569-1.7488-3.7024-3.8013-3.8007z</StreamGeometry>
|
||||
|
||||
|
||||
<MenuFlyout x:Key="DefaultTextBoxContextFlyout" ShowMode="{OnFormFactor Desktop=Standard, Mobile=Transient}">
|
||||
<MenuItem Header="{DynamicResource StringTextFlyoutCutText}" Command="{Binding $parent[TextBox].Cut}" IsEnabled="{Binding $parent[TextBox].CanCut}" InputGesture="{x:Static TextBox.CutGesture}" />
|
||||
<MenuItem Header="{DynamicResource StringTextFlyoutCopyText}" Command="{Binding $parent[TextBox].Copy}" IsEnabled="{Binding $parent[TextBox].CanCopy}" InputGesture="{x:Static TextBox.CopyGesture}"/>
|
||||
@@ -99,6 +99,7 @@
|
||||
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource TextControlSelectionHighlightColor}" />
|
||||
<Setter Property="PlaceholderForeground" Value="{DynamicResource TextControlPlaceholderForeground}" />
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
|
||||
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
|
||||
@@ -132,11 +133,12 @@
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="1"
|
||||
Margin="{TemplateBinding Padding}">
|
||||
<TextBlock Name="PART_FloatingWatermark"
|
||||
Foreground="{DynamicResource SystemAccentColor}"
|
||||
<TextBlock Name="PART_FloatingPlaceholder"
|
||||
Foreground="{TemplateBinding PlaceholderForeground}"
|
||||
IsVisible="False"
|
||||
Text="{TemplateBinding Watermark}"
|
||||
Text="{TemplateBinding PlaceholderText}"
|
||||
DockPanel.Dock="Top" />
|
||||
|
||||
<ScrollViewer Name="PART_ScrollViewer"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}"
|
||||
@@ -144,9 +146,10 @@
|
||||
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}">
|
||||
<Panel>
|
||||
<TextBlock Name="PART_Watermark"
|
||||
<TextBlock Name="PART_Placeholder"
|
||||
Foreground="{TemplateBinding PlaceholderForeground}"
|
||||
Opacity="{DynamicResource TextControlPlaceholderOpacity}"
|
||||
Text="{TemplateBinding Watermark}"
|
||||
Text="{TemplateBinding PlaceholderText}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
@@ -158,6 +161,7 @@
|
||||
</MultiBinding>
|
||||
</TextBlock.IsVisible>
|
||||
</TextBlock>
|
||||
|
||||
<TextPresenter Name="PART_TextPresenter"
|
||||
Text="{TemplateBinding Text, Mode=TwoWay}"
|
||||
CaretBlinkInterval="{TemplateBinding CaretBlinkInterval}"
|
||||
@@ -203,9 +207,6 @@
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ TextBlock#PART_Watermark, ^ /template/ TextBlock#PART_FloatingWatermark">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundDisabled}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<!-- PointerOver State-->
|
||||
@@ -217,19 +218,12 @@
|
||||
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ TextBlock#PART_Watermark">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundPointerOver}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<!-- Focused State -->
|
||||
<Style Selector="^:focus">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundFocused}" />
|
||||
|
||||
<Style Selector="^ /template/ TextBlock#PART_Watermark">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundFocused}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundFocused}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushFocused}"/>
|
||||
@@ -241,14 +235,15 @@
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlErrorTextForegroundBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ TextBlock#PART_FloatingWatermark">
|
||||
<Style Selector="^ /template/ TextBlock#PART_FloatingPlaceholder">
|
||||
<Setter Property="Cursor" Value="IBeam"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^[UseFloatingWatermark=true]:not(:empty) /template/ TextBlock#PART_FloatingWatermark">
|
||||
|
||||
<Style Selector="^[UseFloatingPlaceholder=true]:not(:empty) /template/ TextBlock#PART_FloatingPlaceholder">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
|
||||
|
||||
<Style Selector="^.revealPasswordButton[AcceptsReturn=False][IsReadOnly=False]:not(TextBox:empty)">
|
||||
<Setter Property="InnerRightContent">
|
||||
<Template>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<x:String x:Key="StringTextFlyoutCopyText">Copy</x:String>
|
||||
<x:String x:Key="StringTextFlyoutPasteText">Paste</x:String>
|
||||
<!-- ManagedFileChooser -->
|
||||
<x:String x:Key="StringManagedFileChooserFileNameWatermark">File name</x:String>
|
||||
<x:String x:Key="StringManagedFileChooserFileNamePlaceholder">File name</x:String>
|
||||
<x:String x:Key="StringManagedFileChooserShowHiddenFilesText">Show hidden files</x:String>
|
||||
<x:String x:Key="StringManagedFileChooserOkText">OK</x:String>
|
||||
<x:String x:Key="StringManagedFileChooserCancelText">Cancel</x:String>
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}"
|
||||
ClearSelectionOnLostFocus="{TemplateBinding ClearSelectionOnLostFocus}"
|
||||
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
|
||||
Watermark="{TemplateBinding Watermark}"
|
||||
MaxLength="{TemplateBinding MaxLength}"
|
||||
PlaceholderText="{TemplateBinding PlaceholderText}"
|
||||
PlaceholderForeground="{TemplateBinding PlaceholderForeground}"
|
||||
MaxLength="{TemplateBinding MaxLength}"
|
||||
InnerLeftContent="{TemplateBinding InnerLeftContent}"
|
||||
InnerRightContent="{TemplateBinding InnerRightContent}"
|
||||
/>
|
||||
|
||||
@@ -101,8 +101,9 @@
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
|
||||
UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}"
|
||||
Watermark="{TemplateBinding Watermark}" />
|
||||
UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}"
|
||||
PlaceholderText="{TemplateBinding PlaceholderText}"
|
||||
PlaceholderForeground="{TemplateBinding PlaceholderForeground}" />
|
||||
|
||||
<Button Name="PART_Button"
|
||||
Grid.Column="1"
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<TextBox DockPanel.Dock="Bottom"
|
||||
IsVisible="{Binding !SelectingFolder}"
|
||||
Text="{Binding FileName}"
|
||||
Watermark="{DynamicResource StringManagedFileChooserFileNameWatermark}" />
|
||||
PlaceholderText="{DynamicResource StringManagedFileChooserFileNamePlaceholder}" />
|
||||
|
||||
<ListBox x:Name="PART_QuickLinks"
|
||||
MaxWidth="200"
|
||||
@@ -264,7 +264,7 @@
|
||||
<Binding Path ="FileName" RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</TextBlock>
|
||||
<StackPanel HorizontalAlignment="Right"
|
||||
Spacing="10"
|
||||
Orientation="Horizontal">
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
Text="{TemplateBinding Text}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="NoWrap"
|
||||
Watermark="{TemplateBinding Watermark}"
|
||||
PlaceholderText="{TemplateBinding PlaceholderText}"
|
||||
PlaceholderForeground="{TemplateBinding PlaceholderForeground}"
|
||||
InnerLeftContent="{Binding InnerLeftContent, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
InnerRightContent="{Binding InnerRightContent, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</ButtonSpinner>
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
|
||||
<Setter Property="PlaceholderForeground" Value="{DynamicResource ThemeForegroundLowBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}" />
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource HighlightBrush}" />
|
||||
<Setter Property="SelectionForegroundBrush" Value="{DynamicResource HighlightForegroundBrush}" />
|
||||
@@ -102,14 +103,14 @@
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
||||
|
||||
<TextBlock Name="floatingWatermark"
|
||||
<TextBlock Name="floatingPlaceholder"
|
||||
DockPanel.Dock="Top"
|
||||
FontSize="{DynamicResource FontSizeSmall}"
|
||||
Foreground="{DynamicResource ThemeAccentBrush}"
|
||||
Text="{TemplateBinding Watermark}">
|
||||
Foreground="{TemplateBinding PlaceholderForeground}"
|
||||
Text="{TemplateBinding PlaceholderText}">
|
||||
<TextBlock.IsVisible>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="UseFloatingWatermark"
|
||||
<Binding Path="UseFloatingPlaceholder"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding Converter="{x:Static StringConverters.IsNotNullOrEmpty}"
|
||||
Path="Text"
|
||||
@@ -133,11 +134,12 @@
|
||||
IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
|
||||
<Panel>
|
||||
<TextBlock Name="watermark"
|
||||
<TextBlock Name="placeholder"
|
||||
Foreground="{TemplateBinding PlaceholderForeground}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Opacity="{DynamicResource TextControlPlaceholderOpacity}"
|
||||
Text="{TemplateBinding Watermark}"
|
||||
Text="{TemplateBinding PlaceholderText}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}">
|
||||
<TextBlock.IsVisible>
|
||||
@@ -194,7 +196,7 @@
|
||||
<Style Selector="^:disabled /template/ Border#border">
|
||||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ TextBlock#floatingWatermark">
|
||||
<Style Selector="^ /template/ TextBlock#floatingPlaceholder">
|
||||
<Setter Property="Cursor" Value="IBeam"/>
|
||||
</Style>
|
||||
|
||||
@@ -203,7 +205,7 @@
|
||||
<Template>
|
||||
<Button Command="{Binding $parent[TextBox].Clear}"
|
||||
Focusable="False"
|
||||
Theme="{StaticResource SimpleTextBoxClearButtonTheme}"
|
||||
Theme="{StaticResource SimpleTextBoxClearButtonTheme}"
|
||||
ClipToBounds="True" />
|
||||
</Template>
|
||||
</Setter>
|
||||
|
||||
@@ -406,7 +406,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.Equal(control.Text, control.ItemSelector(input, selectedItem));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Text_Validation()
|
||||
{
|
||||
@@ -421,7 +421,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.Equal([exception], DataValidationErrors.GetErrors(control));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Text_Validation_TextBox_Errors_Binding()
|
||||
{
|
||||
@@ -430,20 +430,20 @@ namespace Avalonia.Controls.UnitTests
|
||||
// simulate the TemplateBinding that would be used within the AutoCompleteBox control theme for the inner PART_TextBox
|
||||
// DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
|
||||
textbox.Bind(DataValidationErrors.ErrorsProperty, control.GetBindingObservable(DataValidationErrors.ErrorsProperty));
|
||||
|
||||
|
||||
var exception = new InvalidCastException("failed validation");
|
||||
var textObservable = new BehaviorSubject<BindingNotification>(new BindingNotification(exception, BindingErrorType.DataValidationError));
|
||||
control.Bind(AutoCompleteBox.TextProperty, textObservable);
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
|
||||
|
||||
Assert.True(DataValidationErrors.GetHasErrors(control));
|
||||
Assert.Equal([exception], DataValidationErrors.GetErrors(control));
|
||||
|
||||
|
||||
Assert.True(DataValidationErrors.GetHasErrors(textbox));
|
||||
Assert.Equal([exception], DataValidationErrors.GetErrors(textbox));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SelectedItem_Validation()
|
||||
{
|
||||
@@ -583,7 +583,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a defined predicate filter through a new AutoCompleteBox
|
||||
/// Retrieves a defined predicate filter through a new AutoCompleteBox
|
||||
/// control instance.
|
||||
/// </summary>
|
||||
/// <param name="mode">The FilterMode of interest.</param>
|
||||
@@ -1283,5 +1283,18 @@ namespace Avalonia.Controls.UnitTests
|
||||
IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaceholderForeground_Can_Be_Set()
|
||||
{
|
||||
using (UnitTestApplication.Start(TestServices.StyledWindow))
|
||||
{
|
||||
var control = CreateControl();
|
||||
control.PlaceholderText = "Search...";
|
||||
control.PlaceholderForeground = Media.Brushes.Green;
|
||||
|
||||
Assert.Equal(Media.Brushes.Green, control.PlaceholderForeground);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
{
|
||||
return new FuncControlTemplate<CalendarDatePicker>((control, scope) =>
|
||||
{
|
||||
var textBox =
|
||||
var textBox =
|
||||
new TextBox
|
||||
{
|
||||
Name = "PART_TextBox"
|
||||
@@ -130,7 +130,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
var calendar =
|
||||
new Calendar
|
||||
{
|
||||
Name = "PART_Calendar",
|
||||
Name = "PART_Calendar",
|
||||
[!Calendar.SelectedDateProperty] = control[!CalendarDatePicker.SelectedDateProperty],
|
||||
[!Calendar.DisplayDateProperty] = control[!CalendarDatePicker.DisplayDateProperty],
|
||||
[!Calendar.DisplayDateStartProperty] = control[!CalendarDatePicker.DisplayDateStartProperty],
|
||||
@@ -179,5 +179,18 @@ namespace Avalonia.Controls.UnitTests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaceholderForeground_Can_Be_Set()
|
||||
{
|
||||
using (UnitTestApplication.Start(Services))
|
||||
{
|
||||
var control = CreateControl();
|
||||
control.PlaceholderText = "Select date";
|
||||
control.PlaceholderForeground = Media.Brushes.Purple;
|
||||
|
||||
Assert.Equal(Media.Brushes.Purple, control.PlaceholderForeground);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
@@ -58,7 +58,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
var spinner = GetSpinner(control);
|
||||
|
||||
spinner.RaiseEvent(new SpinEventArgs(Spinner.SpinEvent, direction));
|
||||
|
||||
|
||||
Assert.Equal(control.Value, expected);
|
||||
}
|
||||
|
||||
@@ -105,16 +105,16 @@ namespace Avalonia.Controls.UnitTests
|
||||
// if min and max are not defined and value was null, 0 should be ne new value after spin
|
||||
yield return [decimal.MinValue, decimal.MaxValue, null, SpinDirection.Decrease, 0m];
|
||||
yield return [decimal.MinValue, decimal.MaxValue, null, SpinDirection.Increase, 0m];
|
||||
|
||||
|
||||
// if no value was defined, but Min or Max are defined, use these as the new value
|
||||
yield return [-400m, -200m, null, SpinDirection.Decrease, -200m];
|
||||
yield return [200m, 400m, null, SpinDirection.Increase, 200m];
|
||||
|
||||
|
||||
// Value should be clamped to Min / Max after spinning
|
||||
yield return [200m, 400m, 5m, SpinDirection.Increase, 200m];
|
||||
yield return [200m, 400m, 200m, SpinDirection.Decrease, 200m];
|
||||
}
|
||||
|
||||
|
||||
private void RunTest(Action<NumericUpDown, TextBox> test)
|
||||
{
|
||||
using (UnitTestApplication.Start(Services))
|
||||
@@ -148,14 +148,14 @@ namespace Avalonia.Controls.UnitTests
|
||||
.OfType<TextBox>()
|
||||
.First();
|
||||
}
|
||||
|
||||
|
||||
private static ButtonSpinner GetSpinner(NumericUpDown control)
|
||||
{
|
||||
return control.GetTemplateChildren()
|
||||
.OfType<ButtonSpinner>()
|
||||
.First();
|
||||
}
|
||||
|
||||
|
||||
private static IControlTemplate CreateTemplate()
|
||||
{
|
||||
return new FuncControlTemplate<NumericUpDown>((control, scope) =>
|
||||
@@ -180,14 +180,27 @@ namespace Avalonia.Controls.UnitTests
|
||||
{
|
||||
// Set TabIndex on NumericUpDown
|
||||
control.TabIndex = 5;
|
||||
|
||||
|
||||
// The inner TextBox should inherit the same TabIndex
|
||||
Assert.Equal(5, textbox.TabIndex);
|
||||
|
||||
|
||||
// Change TabIndex and verify it gets synchronized
|
||||
control.TabIndex = 10;
|
||||
Assert.Equal(10, textbox.TabIndex);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaceholderForeground_Can_Be_Set()
|
||||
{
|
||||
using (UnitTestApplication.Start(Services))
|
||||
{
|
||||
var control = CreateControl();
|
||||
control.PlaceholderText = "Enter value";
|
||||
control.PlaceholderForeground = Media.Brushes.Red;
|
||||
|
||||
Assert.Equal(Media.Brushes.Red, control.PlaceholderForeground);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,25 +42,25 @@ namespace Avalonia.Controls.UnitTests
|
||||
Template = CreateTemplate(),
|
||||
Text = "5678"
|
||||
};
|
||||
|
||||
|
||||
var sp = new StackPanel();
|
||||
sp.Children.Add(target1);
|
||||
sp.Children.Add(target2);
|
||||
|
||||
target1.ApplyTemplate();
|
||||
target2.ApplyTemplate();
|
||||
|
||||
|
||||
var root = new TestRoot() { Child = sp };
|
||||
|
||||
target1.SelectionStart = 0;
|
||||
target1.SelectionEnd = 3;
|
||||
|
||||
|
||||
target1.Focus();
|
||||
Assert.False(target2.IsFocused);
|
||||
Assert.True(target1.IsFocused);
|
||||
|
||||
target2.Focus();
|
||||
|
||||
|
||||
Assert.Equal("123", target1.SelectedText);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
target1.ApplyTemplate();
|
||||
|
||||
@@ -165,16 +165,16 @@ namespace Avalonia.Controls.UnitTests
|
||||
};
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
|
||||
target.Measure(Size.Infinity);
|
||||
|
||||
|
||||
target.CaretIndex = 3;
|
||||
RaiseKeyEvent(target, Key.Right, 0);
|
||||
|
||||
Assert.Equal(4, target.CaretIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Control_Backspace_Should_Set_Caret_Position_To_The_Start_Of_The_Deletion()
|
||||
{
|
||||
@@ -194,11 +194,11 @@ namespace Avalonia.Controls.UnitTests
|
||||
// (First Second |Third)
|
||||
RaiseKeyEvent(target, Key.Back, KeyModifiers.Control);
|
||||
// (First |Third)
|
||||
|
||||
|
||||
Assert.Equal(6, target.CaretIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Control_Backspace_Should_Remove_The_Double_Whitespace_If_Caret_Index_Was_At_The_End_Of_A_Word()
|
||||
{
|
||||
@@ -213,7 +213,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
};
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
|
||||
// (First Second| Third)
|
||||
RaiseKeyEvent(target, Key.Back, KeyModifiers.Control);
|
||||
// (First| Third)
|
||||
@@ -236,11 +236,11 @@ namespace Avalonia.Controls.UnitTests
|
||||
};
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
|
||||
// (First Second| Third)
|
||||
RaiseKeyEvent(target, Key.Back, KeyModifiers.Control);
|
||||
// (First| Third)
|
||||
|
||||
|
||||
target.Undo();
|
||||
// (First Second| Third)
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Template = CreateTemplate(),
|
||||
Text = "1234"
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
RaiseKeyEvent(target, Key.A, KeyModifiers.Control);
|
||||
@@ -314,7 +314,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
SelectionStart = 5,
|
||||
SelectionEnd = 5
|
||||
};
|
||||
|
||||
|
||||
textBox.ApplyTemplate();
|
||||
|
||||
// (First| Second Third Fourth)
|
||||
@@ -356,7 +356,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Text = "First Second Third Fourth",
|
||||
CaretIndex = 19,
|
||||
};
|
||||
|
||||
|
||||
textBox.ApplyTemplate();
|
||||
|
||||
// (First Second Third |Fourth)
|
||||
@@ -400,7 +400,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
|
||||
textBox.SelectionStart = 2;
|
||||
textBox.SelectionEnd = 2;
|
||||
|
||||
|
||||
Assert.Equal(2, textBox.CaretIndex);
|
||||
}
|
||||
}
|
||||
@@ -443,7 +443,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
AcceptsReturn = false,
|
||||
Text = "1234"
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
RaiseKeyEvent(target, Key.Enter, 0);
|
||||
@@ -462,7 +462,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Template = CreateTemplate(),
|
||||
AcceptsReturn = true
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
RaiseKeyEvent(target, Key.Enter, 0);
|
||||
@@ -482,7 +482,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
AcceptsReturn = true,
|
||||
NewLine = "Test"
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
RaiseKeyEvent(target, Key.Enter, 0);
|
||||
@@ -523,7 +523,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Template = CreateTemplate(),
|
||||
Text = "0123456789"
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
target.SelectionStart = 0;
|
||||
@@ -547,7 +547,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Template = CreateTemplate(),
|
||||
Text = "0123456789"
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
target.SelectionStart = 8;
|
||||
@@ -592,7 +592,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Template = CreateTemplate(),
|
||||
Text = "0123456789"
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
Assert.True(target.SelectedText == "");
|
||||
@@ -614,7 +614,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Template = CreateTemplate(),
|
||||
Text = "0123"
|
||||
};
|
||||
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
target.SelectedText = "AA";
|
||||
@@ -679,7 +679,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.True(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData(Key.Up)]
|
||||
[InlineData(Key.Down)]
|
||||
@@ -725,7 +725,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
|
||||
target1.ApplyTemplate();
|
||||
target2.ApplyTemplate();
|
||||
|
||||
|
||||
var root = new TestRoot { Child = sp };
|
||||
|
||||
var gfcount = 0;
|
||||
@@ -746,7 +746,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.Equal(1, lfcount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TextBox_CaretIndex_Persists_When_Focus_Lost()
|
||||
{
|
||||
@@ -768,7 +768,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
|
||||
target1.ApplyTemplate();
|
||||
target2.ApplyTemplate();
|
||||
|
||||
|
||||
var root = new TestRoot { Child = sp };
|
||||
|
||||
target2.Focus();
|
||||
@@ -777,11 +777,11 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.True(target2.IsFocused);
|
||||
|
||||
target1.Focus();
|
||||
|
||||
|
||||
Assert.Equal(2, target2.CaretIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TextBox_Reveal_Password_Reset_When_Lost_Focus()
|
||||
{
|
||||
@@ -804,14 +804,14 @@ namespace Avalonia.Controls.UnitTests
|
||||
|
||||
target1.ApplyTemplate();
|
||||
target2.ApplyTemplate();
|
||||
|
||||
|
||||
var root = new TestRoot { Child = sp };
|
||||
|
||||
target1.Focus();
|
||||
target1.RevealPassword = true;
|
||||
|
||||
|
||||
target2.Focus();
|
||||
|
||||
|
||||
Assert.False(target1.RevealPassword);
|
||||
}
|
||||
}
|
||||
@@ -833,7 +833,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.Null(target.Text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("abc", "d", 3, 0, 0, false, "abc")]
|
||||
[InlineData("abc", "dd", 4, 3, 3, false, "abcd")]
|
||||
@@ -870,7 +870,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
topLevel.LayoutManager.ExecuteInitialLayoutPass();
|
||||
|
||||
target.Measure(Size.Infinity);
|
||||
|
||||
|
||||
if (fromClipboard)
|
||||
{
|
||||
await topLevel.Clipboard!.SetTextAsync(textInput);
|
||||
@@ -882,7 +882,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
{
|
||||
RaiseTextEvent(target, textInput);
|
||||
}
|
||||
|
||||
|
||||
Assert.Equal(expected, target.Text);
|
||||
}
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.Equal((minLines * target.LineHeight) + textPresenterMargin.Top + textPresenterMargin.Bottom, scrollViewer.MinHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, 1)]
|
||||
[InlineData("", 1)]
|
||||
@@ -1285,7 +1285,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
var b = new TextBox();
|
||||
Assert.Equal(-1, b.GetLineCount());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void LineCount_Is_Correct_After_Text_Change()
|
||||
{
|
||||
@@ -1309,7 +1309,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
|
||||
target.ApplyTemplate();
|
||||
target.Measure(Size.Infinity);
|
||||
|
||||
|
||||
Assert.Equal(1, target.GetLineCount());
|
||||
|
||||
target.Text = "Hello\r\nWorld";
|
||||
@@ -1505,7 +1505,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.Equal("ABCDEF123", tb.Text);
|
||||
|
||||
// Undo will take us back one step
|
||||
tb.Undo();
|
||||
tb.Undo();
|
||||
Assert.Equal("ABCDEF", tb.Text);
|
||||
|
||||
// Undo again
|
||||
@@ -2050,7 +2050,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.NotNull(client);
|
||||
Assert.Equal(string.Empty, client.SurroundingText);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Backspace_Should_Delete_Last_Character_In_Line_And_Keep_Caret_On_Same_Line()
|
||||
{
|
||||
@@ -2122,7 +2122,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
|
||||
Assert.True(target1.IsFocused);
|
||||
|
||||
Assert.Equal("1234", target1.SelectedText);
|
||||
Assert.Equal("1234", target1.SelectedText);
|
||||
|
||||
target2.Focus();
|
||||
|
||||
@@ -2149,6 +2149,61 @@ namespace Avalonia.Controls.UnitTests
|
||||
Assert.Equal("FirstSecond", target.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaceholderForeground_Can_Be_Set()
|
||||
{
|
||||
using (UnitTestApplication.Start(Services))
|
||||
{
|
||||
var target = new TextBox
|
||||
{
|
||||
Template = CreateTemplate(),
|
||||
PlaceholderText = "Enter text",
|
||||
PlaceholderForeground = Brushes.Red
|
||||
};
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
Assert.Equal(Brushes.Red, target.PlaceholderForeground);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaceholderForeground_Defaults_To_Null()
|
||||
{
|
||||
using (UnitTestApplication.Start(Services))
|
||||
{
|
||||
var target = new TextBox
|
||||
{
|
||||
Template = CreateTemplate(),
|
||||
PlaceholderText = "Enter text"
|
||||
};
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
Assert.Null(target.PlaceholderForeground);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaceholderForeground_Can_Be_Set_To_Null()
|
||||
{
|
||||
using (UnitTestApplication.Start(Services))
|
||||
{
|
||||
var target = new TextBox
|
||||
{
|
||||
Template = CreateTemplate(),
|
||||
PlaceholderText = "Enter text",
|
||||
PlaceholderForeground = Brushes.Blue
|
||||
};
|
||||
|
||||
target.ApplyTemplate();
|
||||
|
||||
target.PlaceholderForeground = null;
|
||||
|
||||
Assert.Null(target.PlaceholderForeground);
|
||||
}
|
||||
}
|
||||
|
||||
private static TestServices FocusServices => TestServices.MockThreadingInterface.With(
|
||||
keyboardDevice: () => new KeyboardDevice(),
|
||||
keyboardNavigation: () => new KeyboardNavigationHandler(),
|
||||
@@ -2160,7 +2215,7 @@ namespace Avalonia.Controls.UnitTests
|
||||
private static TestServices Services => TestServices.MockThreadingInterface.With(
|
||||
standardCursorFactory: Mock.Of<ICursorFactory>(),
|
||||
renderInterface: new HeadlessPlatformRenderInterface(),
|
||||
textShaperImpl: new HarfBuzzTextShaper(),
|
||||
textShaperImpl: new HarfBuzzTextShaper(),
|
||||
fontManagerImpl: new TestFontManager(),
|
||||
assetLoader: new StandardAssetLoader());
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
x:Class="Sample.App.AttachedProps"
|
||||
Design.Width="300">
|
||||
<TextBox Name="UserNameTextBox"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
</Window>
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
x:Class="Sample.App.ControlWithoutWindow"
|
||||
Design.Width="300">
|
||||
<TextBox Name="UserNameTextBox"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
</UserControl>
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
x:Class="Sample.App.DataTemplates">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="UserNameTextBox"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<ListBox Name="NamedListBox">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:Name="NamedDataTemplate">
|
||||
<TextBox x:Name="TemplatedTextBox"
|
||||
Watermark="Templated input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Templated input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
<StackPanel>
|
||||
<TextBox Name="FirstNameTextBox"
|
||||
x:FieldModifier="Public"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<TextBox Name="LastNameTextBox"
|
||||
x:FieldModifier="public"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<TextBox Name="PasswordTextBox"
|
||||
x:FieldModifier="protected"
|
||||
Watermark="Password input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Password input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<TextBox Name="ConfirmPasswordTextBox"
|
||||
x:FieldModifier="private"
|
||||
Watermark="Password input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Password input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<Button Name="SignUpButton"
|
||||
x:FieldModifier="NotPublic"
|
||||
Content="Sign up" />
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
x:Class="Sample.App.NamedControl">
|
||||
<TextBox Name="UserNameTextBox"
|
||||
AutomationProperties.Name="The user name"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
</Window>
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
x:Class="Sample.App.NamedControls">
|
||||
<StackPanel>
|
||||
<TextBox Name="UserNameTextBox"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<TextBox Name="PasswordTextBox"
|
||||
Watermark="Password input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Password input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<Button Name="SignUpButton"
|
||||
Content="Sign up" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Sample.App.NoNamedControls">
|
||||
<TextBox Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
<TextBox Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
</Window>
|
||||
@@ -5,15 +5,15 @@
|
||||
<StackPanel>
|
||||
<controls:CustomTextBox Margin="0 10 0 0"
|
||||
Name="UserNameTextBox"
|
||||
Watermark="Please, enter user name..."
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Please, enter user name..."
|
||||
UseFloatingPlaceholder="True" />
|
||||
<TextBlock Name="UserNameValidation"
|
||||
Foreground="Red"
|
||||
FontSize="12" />
|
||||
<TextBox Margin="0 10 0 0"
|
||||
Name="PasswordTextBox"
|
||||
Watermark="Please, enter your password..."
|
||||
UseFloatingWatermark="True"
|
||||
Placeholder="Please, enter your password..."
|
||||
UseFloatingPlaceholder="True"
|
||||
PasswordChar="*" />
|
||||
<TextBlock Name="PasswordValidation"
|
||||
Foreground="Red"
|
||||
@@ -27,8 +27,8 @@
|
||||
</ListBox>
|
||||
<TextBox Margin="0 10 0 0"
|
||||
x:Name="ConfirmPasswordTextBox"
|
||||
Watermark="Please, confirm the password..."
|
||||
UseFloatingWatermark="True"
|
||||
Placeholder="Please, confirm the password..."
|
||||
UseFloatingPlaceholder="True"
|
||||
PasswordChar="*" />
|
||||
<TextBlock x:Name="ConfirmPasswordValidation"
|
||||
TextWrapping="Wrap"
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
x:Class="Sample.App.xNamedControl">
|
||||
<TextBox x:Name="UserNameTextBox"
|
||||
AutomationProperties.Name="The user name"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
</Window>
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
x:Class="Sample.App.xNamedControls">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="UserNameTextBox"
|
||||
Watermark="Username input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Username input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<TextBox x:Name="PasswordTextBox"
|
||||
Watermark="Password input"
|
||||
UseFloatingWatermark="True" />
|
||||
Placeholder="Password input"
|
||||
UseFloatingPlaceholder="True" />
|
||||
<!-- Name generator should still generate members, even if XAML is invalid -->
|
||||
<Button x:Name="SignUpButton"
|
||||
Content="{x:Static NonExistent.Member}" />
|
||||
|
||||
@@ -71,14 +71,14 @@ namespace Avalonia.Markup.Xaml.UnitTests.Data
|
||||
<Window xmlns='https://github.com/avaloniaui'
|
||||
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
|
||||
xmlns:local='clr-namespace:Avalonia.Markup.Xaml.UnitTests.Data;assembly=Avalonia.Markup.Xaml.UnitTests'>
|
||||
<TextBox Name='textBox' Text='Foo' Watermark='Bar'>
|
||||
<TextBox Name='textBox' Text='Foo' PlaceholderText='Bar'>
|
||||
<TextBox.Template>
|
||||
<ControlTemplate>
|
||||
<TextPresenter Name='PART_TextPresenter'>
|
||||
<TextPresenter.Text>
|
||||
<MultiBinding Converter='{x:Static local:ConcatConverter.Instance}'>
|
||||
<Binding RelativeSource='{RelativeSource TemplatedParent}' Path='Text'/>
|
||||
<Binding RelativeSource='{RelativeSource TemplatedParent}' Path='Watermark'/>
|
||||
<Binding RelativeSource='{RelativeSource TemplatedParent}' Path='PlaceholderText'/>
|
||||
</MultiBinding>
|
||||
</TextPresenter.Text>
|
||||
</TextPresenter>
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Presenters;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Xunit;
|
||||
|
||||
namespace Avalonia.Skia.RenderTests
|
||||
{
|
||||
public class TextBoxTests : TestBase
|
||||
{
|
||||
public TextBoxTests()
|
||||
: base(@"Controls\TextBox")
|
||||
{
|
||||
}
|
||||
|
||||
private static IControlTemplate CreateTextBoxTemplate()
|
||||
{
|
||||
return new FuncControlTemplate<TextBox>((textBox, scope) =>
|
||||
{
|
||||
var border = new Border
|
||||
{
|
||||
Background = textBox.Background,
|
||||
BorderBrush = Brushes.Gray,
|
||||
BorderThickness = new Thickness(1),
|
||||
Padding = new Thickness(4),
|
||||
};
|
||||
|
||||
var panel = new Panel();
|
||||
|
||||
// Use Antialias mode
|
||||
TextOptions.SetTextRenderingMode(panel, TextRenderingMode.Antialias);
|
||||
|
||||
var placeholder = new TextBlock
|
||||
{
|
||||
Name = "PART_Placeholder",
|
||||
[!TextBlock.TextProperty] = textBox[!TextBox.PlaceholderTextProperty],
|
||||
[!TextBlock.ForegroundProperty] = textBox[!TextBox.PlaceholderForegroundProperty],
|
||||
FontFamily = textBox.FontFamily,
|
||||
FontSize = textBox.FontSize,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Opacity = 0.5,
|
||||
}.RegisterInNameScope(scope);
|
||||
|
||||
var presenter = new TextPresenter
|
||||
{
|
||||
Name = "PART_TextPresenter",
|
||||
[!TextPresenter.TextProperty] = textBox[!TextBox.TextProperty],
|
||||
[!TextPresenter.CaretIndexProperty] = textBox[!TextBox.CaretIndexProperty],
|
||||
FontFamily = textBox.FontFamily,
|
||||
FontSize = textBox.FontSize,
|
||||
}.RegisterInNameScope(scope);
|
||||
|
||||
panel.Children.Add(placeholder);
|
||||
panel.Children.Add(presenter);
|
||||
border.Child = panel;
|
||||
|
||||
return border;
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Placeholder_With_Red_Foreground()
|
||||
{
|
||||
var target = new Border
|
||||
{
|
||||
Padding = new Thickness(8),
|
||||
Width = 200,
|
||||
Height = 50,
|
||||
Background = Brushes.White,
|
||||
Child = new TextBox
|
||||
{
|
||||
Template = CreateTextBoxTemplate(),
|
||||
FontFamily = TestFontFamily,
|
||||
FontSize = 12,
|
||||
Background = Brushes.White,
|
||||
PlaceholderText = "Red placeholder",
|
||||
PlaceholderForeground = Brushes.Red,
|
||||
}
|
||||
};
|
||||
|
||||
await RenderToFile(target);
|
||||
CompareImages();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Placeholder_With_Blue_Foreground()
|
||||
{
|
||||
var target = new Border
|
||||
{
|
||||
Padding = new Thickness(8),
|
||||
Width = 200,
|
||||
Height = 50,
|
||||
Background = Brushes.White,
|
||||
Child = new TextBox
|
||||
{
|
||||
Template = CreateTextBoxTemplate(),
|
||||
FontFamily = TestFontFamily,
|
||||
FontSize = 12,
|
||||
Background = Brushes.White,
|
||||
PlaceholderText = "Blue placeholder",
|
||||
PlaceholderForeground = Brushes.Blue,
|
||||
}
|
||||
};
|
||||
|
||||
await RenderToFile(target);
|
||||
CompareImages();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Placeholder_With_Default_Foreground()
|
||||
{
|
||||
var target = new Border
|
||||
{
|
||||
Padding = new Thickness(8),
|
||||
Width = 200,
|
||||
Height = 50,
|
||||
Background = Brushes.White,
|
||||
Child = new TextBox
|
||||
{
|
||||
Template = CreateTextBoxTemplate(),
|
||||
FontFamily = TestFontFamily,
|
||||
FontSize = 12,
|
||||
Background = Brushes.White,
|
||||
PlaceholderText = "Default placeholder",
|
||||
PlaceholderForeground = Brushes.Gray,
|
||||
}
|
||||
};
|
||||
|
||||
await RenderToFile(target);
|
||||
CompareImages();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Reference in New Issue
Block a user