Browse Source

Use UseFloatingPlaceholder

pull/20303/head
Javier Suárez Ruiz 1 day ago
parent
commit
be2a8c8bf2
  1. 30
      samples/BindingDemo/MainWindow.xaml
  2. 2
      samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml
  3. 6
      samples/ControlCatalog/Pages/TextBoxPage.xaml
  4. 6
      samples/Generators.Sandbox/Controls/SignUpView.xaml
  5. 14
      samples/IntegrationTestApp/Pages/ScreensPage.axaml
  6. 24
      src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs
  7. 2
      src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs
  8. 22
      src/Avalonia.Controls/TextBox.cs
  9. 2
      src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml
  10. 6
      src/Avalonia.Themes.Fluent/Controls/TextBox.xaml
  11. 2
      src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml
  12. 2
      src/Avalonia.Themes.Simple/Controls/TextBox.xaml

30
samples/BindingDemo/MainWindow.xaml

@ -20,22 +20,22 @@
<StackPanel Orientation="Horizontal">
<StackPanel Margin="18" Spacing="4" Width="200">
<TextBlock FontSize="16" Text="Simple Bindings"/>
<TextBox PlaceholderText="Two Way" UseFloatingPlaceholderText="True" Text="{Binding Path=StringValue}" Name="first"/>
<TextBox PlaceholderText="Two Way (LostFocus)" UseFloatingPlaceholderText="True" Text="{Binding Path=StringValue, UpdateSourceTrigger=LostFocus}"/>
<TextBox PlaceholderText="One Way" UseFloatingPlaceholderText="True" Text="{Binding Path=StringValue, Mode=OneWay}"/>
<TextBox PlaceholderText="One Time" UseFloatingPlaceholderText="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 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 PlaceholderText="Items[1].Value" UseFloatingPlaceholderText="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 PlaceholderText="Boolean String" UseFloatingPlaceholderText="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,17 +43,17 @@
<StackPanel Orientation="Horizontal">
<StackPanel Margin="18" Spacing="4" Width="200" HorizontalAlignment="Left">
<TextBlock FontSize="16" Text="Numeric Bindings"/>
<TextBox PlaceholderText="Double" UseFloatingPlaceholderText="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 PlaceholderText="Value of first TextBox" UseFloatingPlaceholderText="True"
<TextBox PlaceholderText="Value of first TextBox" UseFloatingPlaceholder="True"
Text="{Binding #first.Text, Mode=TwoWay}"/>
<TextBox PlaceholderText="Value of SharedItem.StringValue" UseFloatingPlaceholderText="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 PlaceholderText="Value of SharedItem.StringValue (duplicate)" UseFloatingPlaceholderText="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">
@ -93,17 +93,17 @@
<StackPanel Orientation="Horizontal">
<StackPanel Margin="18" Spacing="4" MinWidth="200" DataContext="{Binding ExceptionDataValidation}">
<TextBlock FontSize="16" Text="Exception Validation"/>
<TextBox PlaceholderText="Less Than 10" UseFloatingPlaceholderText="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 PlaceholderText="Maximum" UseFloatingPlaceholderText="True" Text="{Binding Path=Maximum}"/>
<TextBox PlaceholderText="Value" UseFloatingPlaceholderText="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}">
<TextBlock FontSize="16" Text="Data Annotations Validation"/>
<TextBox PlaceholderText="Phone #" UseFloatingPlaceholderText="True" Text="{Binding PhoneNumber}"/>
<TextBox PlaceholderText="Less Than 10" UseFloatingPlaceholderText="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>

2
samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml

@ -36,7 +36,7 @@
<CalendarDatePicker Margin="0,0,0,8"
Name="DatePicker5"
PlaceholderText="Floating Placeholder"
UseFloatingPlaceholderText="True"/>
UseFloatingPlaceholder="True"/>
<TextBlock Text="PlaceholderText with custom color"/>
<CalendarDatePicker Margin="0,0,0,8"

6
samples/ControlCatalog/Pages/TextBoxPage.xaml

@ -21,14 +21,14 @@
<TextBox Width="200" PlaceholderText="Numeric with placeholder" TextInputOptions.ContentType="Number" />
<TextBox Width="200"
PlaceholderText="Floating Placeholder"
UseFloatingPlaceholderText="True"
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"
UseFloatingPlaceholderText="True"
UseFloatingPlaceholder="True"
PlaceholderForeground="Purple"/>
<MaskedTextBox Width="200" ResetOnSpace="False" Mask="(LLL) 999-0000"/>
@ -42,7 +42,7 @@
PlaceholderText="Password Box"
Classes="revealPasswordButton"
TextInputOptions.ContentType="Password"
UseFloatingPlaceholderText="True"
UseFloatingPlaceholder="True"
PasswordChar="*"
Text="Password" />
<TextBox Width="200" PlaceholderText="Suggestions are hidden" TextInputOptions.ShowSuggestions="False" />

6
samples/Generators.Sandbox/Controls/SignUpView.xaml

@ -18,7 +18,7 @@
x:Name="UserNameTextBox"
Text="{Binding UserName}"
PlaceholderText="Please, enter user name..."
UseFloatingPlaceholderText="True" />
UseFloatingPlaceholder="True" />
<TextBlock x:Name="UserNameValidation"
Text="{Binding UserNameValidation}"
Foreground="Green"
@ -27,7 +27,7 @@
x:Name="PasswordTextBox"
Text="{Binding Password}"
PlaceholderText="Please, enter your password..."
UseFloatingPlaceholderText="True"
UseFloatingPlaceholder="True"
PasswordChar="*" />
<TextBlock x:Name="PasswordValidation"
Text="{Binding PasswordValidation}"
@ -37,7 +37,7 @@
x:Name="ConfirmPasswordTextBox"
Text="{Binding ConfirmPassword}"
PlaceholderText="Please, confirm the password..."
UseFloatingPlaceholderText="True"
UseFloatingPlaceholder="True"
PasswordChar="*" />
<TextBlock x:Name="ConfirmPasswordValidation"
Text="{Binding ConfirmPasswordValidation}"

14
samples/IntegrationTestApp/Pages/ScreensPage.axaml

@ -8,12 +8,12 @@
<Button Name="ScreenRefresh"
Content="Refresh"
Click="ScreenRefresh_Click"/>
<TextBox Name="ScreenName" PlaceholderText="DisplayName" UseFloatingPlaceholderText="true" />
<TextBox Name="ScreenHandle" PlaceholderText="Handle" UseFloatingPlaceholderText="true" />
<TextBox Name="ScreenScaling" PlaceholderText="Scaling" UseFloatingPlaceholderText="true" />
<TextBox Name="ScreenBounds" PlaceholderText="Bounds" UseFloatingPlaceholderText="true" />
<TextBox Name="ScreenWorkArea" PlaceholderText="WorkArea" UseFloatingPlaceholderText="true" />
<TextBox Name="ScreenOrientation" PlaceholderText="Orientation" UseFloatingPlaceholderText="true" />
<TextBox Name="ScreenSameReference" PlaceholderText="Is same reference" UseFloatingPlaceholderText="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>

24
src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs

@ -97,20 +97,20 @@ namespace Avalonia.Controls
public static readonly StyledProperty<string?> WatermarkProperty = PlaceholderTextProperty;
/// <summary>
/// Defines the <see cref="UseFloatingPlaceholderText"/> property.
/// 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> UseFloatingPlaceholderTextProperty =
TextBox.UseFloatingPlaceholderTextProperty.AddOwner<CalendarDatePicker>();
public static readonly StyledProperty<bool> UseFloatingPlaceholderProperty =
TextBox.UseFloatingPlaceholderProperty.AddOwner<CalendarDatePicker>();
/// <summary>
/// Defines the <see cref="UseFloatingWatermark"/> property.
/// </summary>
[Obsolete("Use UseFloatingPlaceholderTextProperty instead.", false)]
[Obsolete("Use UseFloatingPlaceholderProperty instead.", false)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
Justification = "Obsolete property alias for backward compatibility.")]
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty = UseFloatingPlaceholderTextProperty;
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty = UseFloatingPlaceholderProperty;
/// <summary>
/// Defines the <see cref="PlaceholderForeground"/> property.
@ -307,21 +307,21 @@ namespace Avalonia.Controls
set => PlaceholderText = value;
}
/// <inheritdoc cref="TextBox.UseFloatingPlaceholderText"/>
public bool UseFloatingPlaceholderText
/// <inheritdoc cref="TextBox.UseFloatingPlaceholder"/>
public bool UseFloatingPlaceholder
{
get => GetValue(UseFloatingPlaceholderTextProperty);
set => SetValue(UseFloatingPlaceholderTextProperty, value);
get => GetValue(UseFloatingPlaceholderProperty);
set => SetValue(UseFloatingPlaceholderProperty, value);
}
/// <inheritdoc cref="TextBox.UseFloatingWatermark"/>
[Obsolete("Use UseFloatingPlaceholderText instead.", false)]
[Obsolete("Use UseFloatingPlaceholder instead.", false)]
public bool UseFloatingWatermark
{
get => UseFloatingPlaceholderText;
get => UseFloatingPlaceholder;
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
Justification = "Obsolete property setter for backward compatibility.")]
set => UseFloatingPlaceholderText = value;
set => UseFloatingPlaceholder = value;
}
/// <inheritdoc cref="TextBox.PlaceholderForeground"/>

2
src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs

@ -881,7 +881,7 @@ namespace Avalonia.Controls
{
SetCurrentValue(TextProperty, String.Empty);
if (string.IsNullOrEmpty(PlaceholderText) && !UseFloatingPlaceholderText)
if (string.IsNullOrEmpty(PlaceholderText) && !UseFloatingPlaceholder)
{
DateTimeFormatInfo dtfi = DateTimeHelper.GetCurrentDateFormat();
_defaultText = string.Empty;

22
src/Avalonia.Controls/TextBox.cs

@ -195,18 +195,18 @@ namespace Avalonia.Controls
public static readonly StyledProperty<string?> WatermarkProperty = PlaceholderTextProperty;
/// <summary>
/// Defines the <see cref="UseFloatingPlaceholderText"/> property.
/// Defines the <see cref="UseFloatingPlaceholder"/> property.
/// </summary>
public static readonly StyledProperty<bool> UseFloatingPlaceholderTextProperty =
AvaloniaProperty.Register<TextBox, bool>(nameof(UseFloatingPlaceholderText));
public static readonly StyledProperty<bool> UseFloatingPlaceholderProperty =
AvaloniaProperty.Register<TextBox, bool>(nameof(UseFloatingPlaceholder));
/// <summary>
/// Defines the <see cref="UseFloatingWatermark"/> property.
/// </summary>
[Obsolete("Use UseFloatingPlaceholderTextProperty instead.", false)]
[Obsolete("Use UseFloatingPlaceholderProperty instead.", false)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022",
Justification = "Obsolete property alias for backward compatibility.")]
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty = UseFloatingPlaceholderTextProperty;
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty = UseFloatingPlaceholderProperty;
/// <summary>
/// Defines the <see cref="PlaceholderForeground"/> property.
@ -718,23 +718,23 @@ namespace Avalonia.Controls
/// 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 UseFloatingPlaceholderText
public bool UseFloatingPlaceholder
{
get => GetValue(UseFloatingPlaceholderTextProperty);
set => SetValue(UseFloatingPlaceholderTextProperty, value);
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 UseFloatingPlaceholderText instead.", false)]
[Obsolete("Use UseFloatingPlaceholder instead.", false)]
public bool UseFloatingWatermark
{
get => UseFloatingPlaceholderText;
get => UseFloatingPlaceholder;
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
Justification = "Obsolete property setter for backward compatibility.")]
set => UseFloatingPlaceholderText = value;
set => UseFloatingPlaceholder = value;
}
/// <summary>

2
src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml

@ -94,7 +94,7 @@
Padding="{TemplateBinding Padding}"
PlaceholderText="{TemplateBinding PlaceholderText}"
PlaceholderForeground="{TemplateBinding PlaceholderForeground}"
UseFloatingPlaceholderText="{TemplateBinding UseFloatingPlaceholderText}"
UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"

6
src/Avalonia.Themes.Fluent/Controls/TextBox.xaml

@ -10,8 +10,8 @@
<TextBox PasswordChar="*" Classes="revealPasswordButton">Reveal Password</TextBox>
<TextBox PasswordChar="*" Classes="revealPasswordButton" RevealPassword="True">Password Revealed</TextBox>
<TextBox PlaceholderText="Placeholder"/>
<TextBox PlaceholderText="Floating Placeholder" UseFloatingPlaceholderText="True"/>
<TextBox PlaceholderText="Floating Placeholder" UseFloatingPlaceholderText="True">Content</TextBox>
<TextBox PlaceholderText="Floating Placeholder" UseFloatingPlaceholder="True"/>
<TextBox PlaceholderText="Floating Placeholder" UseFloatingPlaceholder="True">Content</TextBox>
</StackPanel>
</Border>
</Design.PreviewWith>
@ -239,7 +239,7 @@
<Setter Property="Cursor" Value="IBeam"/>
</Style>
<Style Selector="^[UseFloatingPlaceholderText=true]:not(:empty) /template/ TextBlock#PART_FloatingPlaceholder">
<Style Selector="^[UseFloatingPlaceholder=true]:not(:empty) /template/ TextBlock#PART_FloatingPlaceholder">
<Setter Property="IsVisible" Value="True" />
</Style>

2
src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml

@ -101,7 +101,7 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
UseFloatingPlaceholderText="{TemplateBinding UseFloatingPlaceholderText}"
UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}"
PlaceholderText="{TemplateBinding PlaceholderText}"
PlaceholderForeground="{TemplateBinding PlaceholderForeground}" />

2
src/Avalonia.Themes.Simple/Controls/TextBox.xaml

@ -110,7 +110,7 @@
Text="{TemplateBinding PlaceholderText}">
<TextBlock.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="UseFloatingPlaceholderText"
<Binding Path="UseFloatingPlaceholder"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Converter="{x:Static StringConverters.IsNotNullOrEmpty}"
Path="Text"

Loading…
Cancel
Save