Browse Source

Merge branch 'fixes/moreTextProcessingFixes' of https://github.com/Gillibald/Avalonia into fixes/moreTextProcessingFixes

pull/10784/head
Benedikt Stebner 3 years ago
parent
commit
a8a0577b53
  1. 2
      src/Avalonia.Base/Layout/Layoutable.cs
  2. 108
      src/Avalonia.Base/Threading/DispatcherPriority.cs
  3. 2
      src/Avalonia.Base/Visual.cs
  4. 2
      src/Avalonia.Controls.ItemsRepeater/Layout/UniformGridLayout.cs
  5. 104
      src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs
  6. 65
      src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs
  7. 2
      src/Avalonia.Controls/Primitives/ScrollBar.cs
  8. 2
      src/Avalonia.Controls/ScrollViewer.cs
  9. 2
      src/Avalonia.Controls/Slider.cs
  10. 2
      src/Avalonia.Controls/TopLevel.cs

2
src/Avalonia.Base/Layout/Layoutable.cs

@ -125,7 +125,7 @@ namespace Avalonia.Layout
AvaloniaProperty.Register<Layoutable, VerticalAlignment>(nameof(VerticalAlignment)); AvaloniaProperty.Register<Layoutable, VerticalAlignment>(nameof(VerticalAlignment));
/// <summary> /// <summary>
/// Defines the <see cref="UseLayoutRoundingProperty"/> property. /// Defines the <see cref="UseLayoutRounding"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<bool> UseLayoutRoundingProperty = public static readonly StyledProperty<bool> UseLayoutRoundingProperty =
AvaloniaProperty.Register<Layoutable, bool>(nameof(UseLayoutRounding), defaultValue: true, inherits: true); AvaloniaProperty.Register<Layoutable, bool>(nameof(UseLayoutRounding), defaultValue: true, inherits: true);

108
src/Avalonia.Base/Threading/DispatcherPriority.cs

@ -16,64 +16,64 @@ namespace Avalonia.Threading
{ {
Value = value; Value = value;
} }
/// <summary>
/// Minimum possible priority that's actually dispatched, default value
/// </summary>
internal static readonly DispatcherPriority MinimumActiveValue = new(0);
/// <summary> /// <summary>
/// A dispatcher priority for jobs that shouldn't be executed yet /// The lowest foreground dispatcher priority
/// </summary> /// </summary>
public static DispatcherPriority Inactive => new(MinimumActiveValue - 1); internal static readonly DispatcherPriority Default = new(0);
/// <summary> /// <summary>
/// Minimum valid priority /// The job will be processed with the same priority as input.
/// </summary> /// </summary>
internal static readonly DispatcherPriority MinValue = new(Inactive); public static readonly DispatcherPriority Input = new(Default - 1);
/// <summary> /// <summary>
/// Used internally in dispatcher code /// The job will be processed after other non-idle operations have completed.
/// </summary> /// </summary>
public static DispatcherPriority Invalid => new(MinimumActiveValue - 2); public static readonly DispatcherPriority Background = new(Input - 1);
/// <summary>
/// The job will be processed after background operations have completed.
/// </summary>
public static readonly DispatcherPriority ContextIdle = new(Background - 1);
/// <summary> /// <summary>
/// The job will be processed when the system is idle. /// The job will be processed when the application is idle.
/// </summary> /// </summary>
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority SystemIdle = MinimumActiveValue; public static readonly DispatcherPriority ApplicationIdle = new (ContextIdle - 1);
/// <summary> /// <summary>
/// The job will be processed when the application is idle. /// The job will be processed when the system is idle.
/// </summary> /// </summary>
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority ApplicationIdle = new (SystemIdle + 1); public static readonly DispatcherPriority SystemIdle = new(ApplicationIdle - 1);
/// <summary> /// <summary>
/// The job will be processed after background operations have completed. /// Minimum possible priority that's actually dispatched, default value
/// </summary> /// </summary>
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority ContextIdle = new(ApplicationIdle + 1); internal static readonly DispatcherPriority MinimumActiveValue = new(SystemIdle);
/// <summary> /// <summary>
/// The job will be processed with normal priority. /// A dispatcher priority for jobs that shouldn't be executed yet
/// </summary> /// </summary>
#pragma warning disable CS0618 public static readonly DispatcherPriority Inactive = new(MinimumActiveValue - 1);
public static readonly DispatcherPriority Normal = new(ContextIdle + 1);
#pragma warning restore CS0618
/// <summary> /// <summary>
/// The job will be processed after other non-idle operations have completed. /// Minimum valid priority
/// </summary> /// </summary>
public static readonly DispatcherPriority Background = new(MinValue + 1); internal static readonly DispatcherPriority MinValue = new(Inactive);
/// <summary> /// <summary>
/// The job will be processed with the same priority as input. /// Used internally in dispatcher code
/// </summary> /// </summary>
public static readonly DispatcherPriority Input = new(Background + 1); public static readonly DispatcherPriority Invalid = new(MinimumActiveValue - 2);
/// <summary> /// <summary>
/// The job will be processed after layout and render but before input. /// The job will be processed after layout and render but before input.
/// </summary> /// </summary>
public static readonly DispatcherPriority Loaded = new(Input + 1); public static readonly DispatcherPriority Loaded = new(Default + 1);
/// <summary> /// <summary>
/// The job will be processed with the same priority as render. /// The job will be processed with the same priority as render.
@ -98,12 +98,19 @@ namespace Avalonia.Threading
/// <summary> /// <summary>
/// The job will be processed with the same priority as data binding. /// The job will be processed with the same priority as data binding.
/// </summary> /// </summary>
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority DataBind = MinValue; [Obsolete("WPF compatibility")] public static readonly DispatcherPriority DataBind = new(Layout);
/// <summary>
/// The job will be processed with normal priority.
/// </summary>
#pragma warning disable CS0618
public static readonly DispatcherPriority Normal = new(DataBind + 1);
#pragma warning restore CS0618
/// <summary> /// <summary>
/// The job will be processed before other asynchronous operations. /// The job will be processed before other asynchronous operations.
/// </summary> /// </summary>
public static readonly DispatcherPriority Send = new(Layout + 1); public static readonly DispatcherPriority Send = new(Normal + 1);
/// <summary> /// <summary>
/// Maximum possible priority /// Maximum possible priority
@ -151,5 +158,42 @@ namespace Avalonia.Threading
if (priority < Inactive || priority > MaxValue) if (priority < Inactive || priority > MaxValue)
throw new ArgumentException("Invalid DispatcherPriority value", parameterName); throw new ArgumentException("Invalid DispatcherPriority value", parameterName);
} }
#pragma warning disable CS0618
public override string ToString()
{
if (this == Invalid)
return nameof(Invalid);
if (this == Inactive)
return nameof(Inactive);
if (this == SystemIdle)
return nameof(SystemIdle);
if (this == ContextIdle)
return nameof(ContextIdle);
if (this == ApplicationIdle)
return nameof(ApplicationIdle);
if (this == Background)
return nameof(Background);
if (this == Input)
return nameof(Input);
if (this == Default)
return nameof(Default);
if (this == Loaded)
return nameof(Loaded);
if (this == Render)
return nameof(Render);
if (this == Composition)
return nameof(Composition);
if (this == PreComposition)
return nameof(PreComposition);
if (this == DataBind)
return nameof(DataBind);
if (this == Normal)
return nameof(Normal);
if (this == Send)
return nameof(Send);
return Value.ToString();
}
#pragma warning restore CS0618
} }
} }

2
src/Avalonia.Base/Visual.cs

@ -50,7 +50,7 @@ namespace Avalonia
AvaloniaProperty.Register<Visual, Geometry?>(nameof(Clip)); AvaloniaProperty.Register<Visual, Geometry?>(nameof(Clip));
/// <summary> /// <summary>
/// Defines the <see cref="IsVisibleProperty"/> property. /// Defines the <see cref="IsVisible"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<bool> IsVisibleProperty = public static readonly StyledProperty<bool> IsVisibleProperty =
AvaloniaProperty.Register<Visual, bool>(nameof(IsVisible), true); AvaloniaProperty.Register<Visual, bool>(nameof(IsVisible), true);

2
src/Avalonia.Controls.ItemsRepeater/Layout/UniformGridLayout.cs

@ -113,7 +113,7 @@ namespace Avalonia.Layout
AvaloniaProperty.Register<UniformGridLayout, double>(nameof(MinRowSpacing)); AvaloniaProperty.Register<UniformGridLayout, double>(nameof(MinRowSpacing));
/// <summary> /// <summary>
/// Defines the <see cref="MaximumRowsOrColumnsProperty"/> property. /// Defines the <see cref="MaximumRowsOrColumns"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<int> MaximumRowsOrColumnsProperty = public static readonly StyledProperty<int> MaximumRowsOrColumnsProperty =
AvaloniaProperty.Register<UniformGridLayout, int>(nameof(MaximumRowsOrColumns)); AvaloniaProperty.Register<UniformGridLayout, int>(nameof(MaximumRowsOrColumns));

104
src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs

@ -52,34 +52,32 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="IsTextCompletionEnabled" /> property.</value> /// <value>The identifier for the <see cref="IsTextCompletionEnabled" /> property.</value>
public static readonly StyledProperty<bool> IsTextCompletionEnabledProperty = public static readonly StyledProperty<bool> IsTextCompletionEnabledProperty =
AvaloniaProperty.Register<AutoCompleteBox, bool>(nameof(IsTextCompletionEnabled)); AvaloniaProperty.Register<AutoCompleteBox, bool>(
nameof(IsTextCompletionEnabled));
/// <summary> /// <summary>
/// Identifies the <see cref="ItemTemplate" /> property. /// Identifies the <see cref="ItemTemplate" /> property.
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="ItemTemplate" /> property.</value> /// <value>The identifier for the <see cref="ItemTemplate" /> property.</value>
public static readonly StyledProperty<IDataTemplate> ItemTemplateProperty = public static readonly StyledProperty<IDataTemplate> ItemTemplateProperty =
AvaloniaProperty.Register<AutoCompleteBox, IDataTemplate>(nameof(ItemTemplate)); AvaloniaProperty.Register<AutoCompleteBox, IDataTemplate>(
nameof(ItemTemplate));
/// <summary> /// <summary>
/// Identifies the <see cref="IsDropDownOpen" /> property. /// Identifies the <see cref="IsDropDownOpen" /> property.
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="IsDropDownOpen" /> property.</value> /// <value>The identifier for the <see cref="IsDropDownOpen" /> property.</value>
public static readonly DirectProperty<AutoCompleteBox, bool> IsDropDownOpenProperty = public static readonly StyledProperty<bool> IsDropDownOpenProperty =
AvaloniaProperty.RegisterDirect<AutoCompleteBox, bool>( AvaloniaProperty.Register<AutoCompleteBox, bool>(
nameof(IsDropDownOpen), nameof(IsDropDownOpen));
o => o.IsDropDownOpen,
(o, v) => o.IsDropDownOpen = v);
/// <summary> /// <summary>
/// Identifies the <see cref="SelectedItem" /> property. /// Identifies the <see cref="SelectedItem" /> property.
/// </summary> /// </summary>
/// <value>The identifier the <see cref="SelectedItem" /> property.</value> /// <value>The identifier the <see cref="SelectedItem" /> property.</value>
public static readonly DirectProperty<AutoCompleteBox, object?> SelectedItemProperty = public static readonly StyledProperty<object?> SelectedItemProperty =
AvaloniaProperty.RegisterDirect<AutoCompleteBox, object?>( AvaloniaProperty.Register<AutoCompleteBox, object?>(
nameof(SelectedItem), nameof(SelectedItem),
o => o.SelectedItem,
(o, v) => o.SelectedItem = v,
defaultBindingMode: BindingMode.TwoWay, defaultBindingMode: BindingMode.TwoWay,
enableDataValidation: true); enableDataValidation: true);
@ -115,58 +113,50 @@ namespace Avalonia.Controls
/// Identifies the <see cref="ItemFilter" /> property. /// Identifies the <see cref="ItemFilter" /> property.
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="ItemFilter" /> property.</value> /// <value>The identifier for the <see cref="ItemFilter" /> property.</value>
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteFilterPredicate<object?>?> ItemFilterProperty = public static readonly StyledProperty<AutoCompleteFilterPredicate<object?>?> ItemFilterProperty =
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteFilterPredicate<object?>?>( AvaloniaProperty.Register<AutoCompleteBox, AutoCompleteFilterPredicate<object?>?>(
nameof(ItemFilter), nameof(ItemFilter));
o => o.ItemFilter,
(o, v) => o.ItemFilter = v);
/// <summary> /// <summary>
/// Identifies the <see cref="TextFilter" /> property. /// Identifies the <see cref="TextFilter" /> property.
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="TextFilter" /> property.</value> /// <value>The identifier for the <see cref="TextFilter" /> property.</value>
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteFilterPredicate<string?>?> TextFilterProperty = public static readonly StyledProperty<AutoCompleteFilterPredicate<string?>?> TextFilterProperty =
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteFilterPredicate<string?>?>( AvaloniaProperty.Register<AutoCompleteBox, AutoCompleteFilterPredicate<string?>?>(
nameof(TextFilter), nameof(TextFilter),
o => o.TextFilter, defaultValue: AutoCompleteSearch.GetFilter(AutoCompleteFilterMode.StartsWith));
(o, v) => o.TextFilter = v,
unsetValue: AutoCompleteSearch.GetFilter(AutoCompleteFilterMode.StartsWith));
/// <summary> /// <summary>
/// Identifies the <see cref="ItemSelector" /> property. /// Identifies the <see cref="ItemSelector" /> property.
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="ItemSelector" /> property.</value> /// <value>The identifier for the <see cref="ItemSelector" /> property.</value>
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteSelector<object>?> ItemSelectorProperty = public static readonly StyledProperty<AutoCompleteSelector<object>?> ItemSelectorProperty =
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteSelector<object>?>( AvaloniaProperty.Register<AutoCompleteBox, AutoCompleteSelector<object>?>(
nameof(ItemSelector), nameof(ItemSelector));
o => o.ItemSelector,
(o, v) => o.ItemSelector = v);
/// <summary> /// <summary>
/// Identifies the <see cref="TextSelector" /> property. /// Identifies the <see cref="TextSelector" /> property.
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="TextSelector" /> property.</value> /// <value>The identifier for the <see cref="TextSelector" /> property.</value>
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteSelector<string?>?> TextSelectorProperty = public static readonly StyledProperty<AutoCompleteSelector<string?>?> TextSelectorProperty =
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteSelector<string?>?>( AvaloniaProperty.Register<AutoCompleteBox, AutoCompleteSelector<string?>?>(
nameof(TextSelector), nameof(TextSelector));
o => o.TextSelector,
(o, v) => o.TextSelector = v);
/// <summary> /// <summary>
/// Identifies the <see cref="Items" /> property. /// Identifies the <see cref="Items" /> property.
/// </summary> /// </summary>
/// <value>The identifier for the <see cref="Items" /> property.</value> /// <value>The identifier for the <see cref="Items" /> property.</value>
public static readonly DirectProperty<AutoCompleteBox, IEnumerable?> ItemsProperty = public static readonly StyledProperty<IEnumerable?> ItemsProperty =
AvaloniaProperty.RegisterDirect<AutoCompleteBox, IEnumerable?>( AvaloniaProperty.Register<AutoCompleteBox, IEnumerable?>(
nameof(Items), nameof(Items));
o => o.Items,
(o, v) => o.Items = v);
public static readonly DirectProperty<AutoCompleteBox, Func<string?, CancellationToken, Task<IEnumerable<object>>>?> AsyncPopulatorProperty = /// <summary>
AvaloniaProperty.RegisterDirect<AutoCompleteBox, Func<string?, CancellationToken, Task<IEnumerable<object>>>?>( /// Identifies the <see cref="AsyncPopulator" /> property.
nameof(AsyncPopulator), /// </summary>
o => o.AsyncPopulator, /// <value>The identifier for the <see cref="AsyncPopulator" /> property.</value>
(o, v) => o.AsyncPopulator = v); public static readonly StyledProperty<Func<string?, CancellationToken, Task<IEnumerable<object>>>?> AsyncPopulatorProperty =
AvaloniaProperty.Register<AutoCompleteBox, Func<string?, CancellationToken, Task<IEnumerable<object>>>?>(
nameof(AsyncPopulator));
/// <summary> /// <summary>
/// Gets or sets the minimum number of characters required to be entered /// Gets or sets the minimum number of characters required to be entered
@ -265,8 +255,8 @@ namespace Avalonia.Controls
/// </value> /// </value>
public bool IsDropDownOpen public bool IsDropDownOpen
{ {
get => _isDropDownOpen; get => GetValue(IsDropDownOpenProperty);
set => SetAndRaise(IsDropDownOpenProperty, ref _isDropDownOpen, value); set => SetValue(IsDropDownOpenProperty, value);
} }
/// <summary> /// <summary>
@ -303,8 +293,8 @@ namespace Avalonia.Controls
/// </remarks> /// </remarks>
public object? SelectedItem public object? SelectedItem
{ {
get => _selectedItem; get => GetValue(SelectedItemProperty);
set => SetAndRaise(SelectedItemProperty, ref _selectedItem, value); set => SetValue(SelectedItemProperty, value);
} }
/// <summary> /// <summary>
@ -388,8 +378,8 @@ namespace Avalonia.Controls
/// </remarks> /// </remarks>
public AutoCompleteFilterPredicate<object?>? ItemFilter public AutoCompleteFilterPredicate<object?>? ItemFilter
{ {
get => _itemFilter; get => GetValue(ItemFilterProperty);
set => SetAndRaise(ItemFilterProperty, ref _itemFilter, value); set => SetValue(ItemFilterProperty, value);
} }
/// <summary> /// <summary>
@ -406,8 +396,8 @@ namespace Avalonia.Controls
/// </remarks> /// </remarks>
public AutoCompleteFilterPredicate<string?>? TextFilter public AutoCompleteFilterPredicate<string?>? TextFilter
{ {
get => _textFilter; get => GetValue(TextFilterProperty);
set => SetAndRaise(TextFilterProperty, ref _textFilter, value); set => SetValue(TextFilterProperty, value);
} }
/// <summary> /// <summary>
@ -420,8 +410,8 @@ namespace Avalonia.Controls
/// </value> /// </value>
public AutoCompleteSelector<object>? ItemSelector public AutoCompleteSelector<object>? ItemSelector
{ {
get => _itemSelector; get => GetValue(ItemSelectorProperty);
set => SetAndRaise(ItemSelectorProperty, ref _itemSelector, value); set => SetValue(ItemSelectorProperty, value);
} }
/// <summary> /// <summary>
@ -436,14 +426,14 @@ namespace Avalonia.Controls
/// </value> /// </value>
public AutoCompleteSelector<string?>? TextSelector public AutoCompleteSelector<string?>? TextSelector
{ {
get => _textSelector; get => GetValue(TextSelectorProperty);
set => SetAndRaise(TextSelectorProperty, ref _textSelector, value); set => SetValue(TextSelectorProperty, value);
} }
public Func<string?, CancellationToken, Task<IEnumerable<object>>>? AsyncPopulator public Func<string?, CancellationToken, Task<IEnumerable<object>>>? AsyncPopulator
{ {
get => _asyncPopulator; get => GetValue(AsyncPopulatorProperty);
set => SetAndRaise(AsyncPopulatorProperty, ref _asyncPopulator, value); set => SetValue(AsyncPopulatorProperty, value);
} }
/// <summary> /// <summary>
@ -454,8 +444,8 @@ namespace Avalonia.Controls
/// drop-down portion of the <see cref="AutoCompleteBox" /> control.</value> /// drop-down portion of the <see cref="AutoCompleteBox" /> control.</value>
public IEnumerable? Items public IEnumerable? Items
{ {
get => _itemsEnumerable; get => GetValue(ItemsProperty);
set => SetAndRaise(ItemsProperty, ref _itemsEnumerable, value); set => SetValue(ItemsProperty, value);
} }
} }
} }

65
src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs

@ -94,8 +94,6 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
private const string ElementTextBox = "PART_TextBox"; private const string ElementTextBox = "PART_TextBox";
private IEnumerable? _itemsEnumerable;
/// <summary> /// <summary>
/// Gets or sets a local cached copy of the items data. /// Gets or sets a local cached copy of the items data.
/// </summary> /// </summary>
@ -188,24 +186,15 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
private IDisposable? _collectionChangeSubscription; private IDisposable? _collectionChangeSubscription;
private Func<string?, CancellationToken, Task<IEnumerable<object>>>? _asyncPopulator;
private CancellationTokenSource? _populationCancellationTokenSource; private CancellationTokenSource? _populationCancellationTokenSource;
private bool _itemTemplateIsFromValueMemberBinding = true; private bool _itemTemplateIsFromValueMemberBinding = true;
private bool _settingItemTemplateFromValueMemberBinding; private bool _settingItemTemplateFromValueMemberBinding;
private object? _selectedItem;
private bool _isDropDownOpen;
private bool _isFocused = false; private bool _isFocused = false;
private string? _searchText = string.Empty; private string? _searchText = string.Empty;
private AutoCompleteFilterPredicate<object?>? _itemFilter;
private AutoCompleteFilterPredicate<string?>? _textFilter = AutoCompleteSearch.GetFilter(AutoCompleteFilterMode.StartsWith);
private AutoCompleteSelector<object>? _itemSelector;
private AutoCompleteSelector<string?>? _textSelector;
private readonly EventHandler _populateDropDownHandler; private readonly EventHandler _populateDropDownHandler;
/// <summary> /// <summary>
@ -264,7 +253,7 @@ namespace Avalonia.Controls
bool isEnabled = (bool)e.NewValue!; bool isEnabled = (bool)e.NewValue!;
if (!isEnabled) if (!isEnabled)
{ {
IsDropDownOpen = false; SetCurrentValue(IsDropDownOpenProperty, false);
} }
} }
@ -388,7 +377,7 @@ namespace Avalonia.Controls
{ {
// Reset the old value before it was incorrectly written // Reset the old value before it was incorrectly written
_ignorePropertyChange = true; _ignorePropertyChange = true;
SetValue(e.Property, e.OldValue); SetCurrentValue(e.Property, e.OldValue);
throw new InvalidOperationException("Cannot set read-only property SearchText."); throw new InvalidOperationException("Cannot set read-only property SearchText.");
} }
@ -403,7 +392,7 @@ namespace Avalonia.Controls
AutoCompleteFilterMode mode = (AutoCompleteFilterMode)e.NewValue!; AutoCompleteFilterMode mode = (AutoCompleteFilterMode)e.NewValue!;
// Sets the filter predicate for the new value // Sets the filter predicate for the new value
TextFilter = AutoCompleteSearch.GetFilter(mode); SetCurrentValue(TextFilterProperty, AutoCompleteSearch.GetFilter(mode));
} }
/// <summary> /// <summary>
@ -417,12 +406,12 @@ namespace Avalonia.Controls
// If null, revert to the "None" predicate // If null, revert to the "None" predicate
if (value == null) if (value == null)
{ {
FilterMode = AutoCompleteFilterMode.None; SetCurrentValue(FilterModeProperty, AutoCompleteFilterMode.None);
} }
else else
{ {
FilterMode = AutoCompleteFilterMode.Custom; SetCurrentValue(FilterModeProperty, AutoCompleteFilterMode.Custom);
TextFilter = null; SetCurrentValue(TextFilterProperty, null);
} }
} }
@ -442,7 +431,7 @@ namespace Avalonia.Controls
} }
private void OnValueMemberBindingChanged(IBinding? value) private void OnValueMemberBindingChanged(IBinding? value)
{ {
if(_itemTemplateIsFromValueMemberBinding) if (_itemTemplateIsFromValueMemberBinding)
{ {
var template = var template =
new FuncDataTemplate( new FuncDataTemplate(
@ -456,7 +445,7 @@ namespace Avalonia.Controls
}); });
_settingItemTemplateFromValueMemberBinding = true; _settingItemTemplateFromValueMemberBinding = true;
ItemTemplate = template; SetCurrentValue(ItemTemplateProperty, template);
_settingItemTemplateFromValueMemberBinding = false; _settingItemTemplateFromValueMemberBinding = false;
} }
} }
@ -713,7 +702,7 @@ namespace Avalonia.Controls
// The drop down is not open, the Down key will toggle it open. // The drop down is not open, the Down key will toggle it open.
if (e.Key == Key.Down) if (e.Key == Key.Down)
{ {
IsDropDownOpen = true; SetCurrentValue(IsDropDownOpenProperty, true);
e.Handled = true; e.Handled = true;
} }
} }
@ -722,7 +711,7 @@ namespace Avalonia.Controls
switch (e.Key) switch (e.Key)
{ {
case Key.F4: case Key.F4:
IsDropDownOpen = !IsDropDownOpen; SetCurrentValue(IsDropDownOpenProperty, !IsDropDownOpen);
e.Handled = true; e.Handled = true;
break; break;
@ -827,7 +816,7 @@ namespace Avalonia.Controls
} }
else else
{ {
IsDropDownOpen = false; SetCurrentValue(IsDropDownOpenProperty, false);
_userCalledPopulate = false; _userCalledPopulate = false;
ClearTextBoxSelection(); ClearTextBoxSelection();
} }
@ -1021,7 +1010,7 @@ namespace Avalonia.Controls
if (args.Cancel) if (args.Cancel)
{ {
_ignorePropertyChange = true; _ignorePropertyChange = true;
SetValue(IsDropDownOpenProperty, oldValue); SetCurrentValue(IsDropDownOpenProperty, oldValue);
} }
else else
{ {
@ -1046,7 +1035,7 @@ namespace Avalonia.Controls
if (args.Cancel) if (args.Cancel)
{ {
_ignorePropertyChange = true; _ignorePropertyChange = true;
SetValue(IsDropDownOpenProperty, oldValue); SetCurrentValue(IsDropDownOpenProperty, oldValue);
} }
else else
{ {
@ -1066,7 +1055,7 @@ namespace Avalonia.Controls
// Force the drop down dependency property to be false. // Force the drop down dependency property to be false.
if (IsDropDownOpen) if (IsDropDownOpen)
{ {
IsDropDownOpen = false; SetCurrentValue(IsDropDownOpenProperty, false);
} }
// Fire the DropDownClosed event // Fire the DropDownClosed event
@ -1088,7 +1077,7 @@ namespace Avalonia.Controls
// Update the prefix/search text. // Update the prefix/search text.
SearchText = Text; SearchText = Text;
if(TryPopulateAsync(SearchText)) if (TryPopulateAsync(SearchText))
{ {
return; return;
} }
@ -1110,7 +1099,7 @@ namespace Avalonia.Controls
_populationCancellationTokenSource?.Dispose(); _populationCancellationTokenSource?.Dispose();
_populationCancellationTokenSource = null; _populationCancellationTokenSource = null;
if(_asyncPopulator == null) if (AsyncPopulator == null)
{ {
return false; return false;
} }
@ -1127,7 +1116,7 @@ namespace Avalonia.Controls
try try
{ {
IEnumerable<object> result = await _asyncPopulator!.Invoke(searchText, cancellationToken); IEnumerable<object> result = await AsyncPopulator!.Invoke(searchText, cancellationToken);
var resultList = result.ToList(); var resultList = result.ToList();
if (cancellationToken.IsCancellationRequested) if (cancellationToken.IsCancellationRequested)
@ -1139,7 +1128,7 @@ namespace Avalonia.Controls
{ {
if (!cancellationToken.IsCancellationRequested) if (!cancellationToken.IsCancellationRequested)
{ {
Items = resultList; SetCurrentValue(ItemsProperty, resultList);
PopulateComplete(); PopulateComplete();
} }
}); });
@ -1199,7 +1188,7 @@ namespace Avalonia.Controls
private string? FormatValue(object? value, bool clearDataContext) private string? FormatValue(object? value, bool clearDataContext)
{ {
string? result = FormatValue(value); string? result = FormatValue(value);
if(clearDataContext && _valueBindingEvaluator != null) if (clearDataContext && _valueBindingEvaluator != null)
{ {
_valueBindingEvaluator.ClearDataContext(); _valueBindingEvaluator.ClearDataContext();
} }
@ -1332,7 +1321,7 @@ namespace Avalonia.Controls
// 1. Minimum prefix length // 1. Minimum prefix length
// 2. If a delay timer is in use, use it // 2. If a delay timer is in use, use it
bool populateReady = newText.Length >= MinimumPrefixLength && MinimumPrefixLength >= 0; bool populateReady = newText.Length >= MinimumPrefixLength && MinimumPrefixLength >= 0;
if(populateReady && MinimumPrefixLength == 0 && String.IsNullOrEmpty(newText) && String.IsNullOrEmpty(SearchText)) if (populateReady && MinimumPrefixLength == 0 && String.IsNullOrEmpty(newText) && String.IsNullOrEmpty(SearchText))
{ {
populateReady = false; populateReady = false;
} }
@ -1361,10 +1350,12 @@ namespace Avalonia.Controls
{ {
_skipSelectedItemTextUpdate = true; _skipSelectedItemTextUpdate = true;
} }
SelectedItem = null;
SetCurrentValue(SelectedItemProperty, null);
if (IsDropDownOpen) if (IsDropDownOpen)
{ {
IsDropDownOpen = false; SetCurrentValue(IsDropDownOpenProperty, false);
} }
} }
} }
@ -1600,7 +1591,7 @@ namespace Avalonia.Controls
if (isDropDownOpen != IsDropDownOpen) if (isDropDownOpen != IsDropDownOpen)
{ {
_ignorePropertyChange = true; _ignorePropertyChange = true;
IsDropDownOpen = isDropDownOpen; SetCurrentValue(IsDropDownOpenProperty, isDropDownOpen);
} }
if (IsDropDownOpen) if (IsDropDownOpen)
{ {
@ -1688,7 +1679,7 @@ namespace Avalonia.Controls
{ {
_skipSelectedItemTextUpdate = true; _skipSelectedItemTextUpdate = true;
} }
SelectedItem = newSelectedItem; SetCurrentValue(SelectedItemProperty, newSelectedItem);
// Restore updates for TextSelection // Restore updates for TextSelection
if (_ignoreTextSelectionChange) if (_ignoreTextSelectionChange)
@ -1784,7 +1775,7 @@ namespace Avalonia.Controls
/// <param name="e">The selection changed event data.</param> /// <param name="e">The selection changed event data.</param>
private void OnAdapterSelectionChanged(object? sender, SelectionChangedEventArgs e) private void OnAdapterSelectionChanged(object? sender, SelectionChangedEventArgs e)
{ {
SelectedItem = _adapter!.SelectedItem; SetCurrentValue(SelectedItemProperty, _adapter!.SelectedItem);
} }
//TODO Check UpdateTextCompletion //TODO Check UpdateTextCompletion
@ -1795,7 +1786,7 @@ namespace Avalonia.Controls
/// <param name="e">The event data.</param> /// <param name="e">The event data.</param>
private void OnAdapterSelectionComplete(object? sender, RoutedEventArgs e) private void OnAdapterSelectionComplete(object? sender, RoutedEventArgs e)
{ {
IsDropDownOpen = false; SetCurrentValue(IsDropDownOpenProperty, false);
// Completion will update the selected value // Completion will update the selected value
//UpdateTextCompletion(false); //UpdateTextCompletion(false);

2
src/Avalonia.Controls/Primitives/ScrollBar.cs

@ -49,7 +49,7 @@ namespace Avalonia.Controls.Primitives
AvaloniaProperty.Register<ScrollBar, Orientation>(nameof(Orientation), Orientation.Vertical); AvaloniaProperty.Register<ScrollBar, Orientation>(nameof(Orientation), Orientation.Vertical);
/// <summary> /// <summary>
/// Defines the <see cref="IsExpandedProperty"/> property. /// Defines the <see cref="IsExpanded"/> property.
/// </summary> /// </summary>
public static readonly DirectProperty<ScrollBar, bool> IsExpandedProperty = public static readonly DirectProperty<ScrollBar, bool> IsExpandedProperty =
AvaloniaProperty.RegisterDirect<ScrollBar, bool>( AvaloniaProperty.RegisterDirect<ScrollBar, bool>(

2
src/Avalonia.Controls/ScrollViewer.cs

@ -200,7 +200,7 @@ namespace Avalonia.Controls
ScrollBarVisibility.Auto); ScrollBarVisibility.Auto);
/// <summary> /// <summary>
/// Defines the <see cref="IsExpandedProperty"/> property. /// Defines the <see cref="IsExpanded"/> property.
/// </summary> /// </summary>
public static readonly DirectProperty<ScrollViewer, bool> IsExpandedProperty = public static readonly DirectProperty<ScrollViewer, bool> IsExpandedProperty =
ScrollBar.IsExpandedProperty.AddOwner<ScrollViewer>(o => o.IsExpanded); ScrollBar.IsExpandedProperty.AddOwner<ScrollViewer>(o => o.IsExpanded);

2
src/Avalonia.Controls/Slider.cs

@ -80,7 +80,7 @@ namespace Avalonia.Controls
AvaloniaProperty.Register<Slider, TickPlacement>(nameof(TickPlacement), 0d); AvaloniaProperty.Register<Slider, TickPlacement>(nameof(TickPlacement), 0d);
/// <summary> /// <summary>
/// Defines the <see cref="TicksProperty"/> property. /// Defines the <see cref="Ticks"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<AvaloniaList<double>?> TicksProperty = public static readonly StyledProperty<AvaloniaList<double>?> TicksProperty =
TickBar.TicksProperty.AddOwner<Slider>(); TickBar.TicksProperty.AddOwner<Slider>();

2
src/Avalonia.Controls/TopLevel.cs

@ -75,7 +75,7 @@ namespace Avalonia.Controls
unsetValue: WindowTransparencyLevel.None); unsetValue: WindowTransparencyLevel.None);
/// <summary> /// <summary>
/// Defines the <see cref="TransparencyBackgroundFallbackProperty"/> property. /// Defines the <see cref="TransparencyBackgroundFallback"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<IBrush> TransparencyBackgroundFallbackProperty = public static readonly StyledProperty<IBrush> TransparencyBackgroundFallbackProperty =
AvaloniaProperty.Register<TopLevel, IBrush>(nameof(TransparencyBackgroundFallback), Brushes.White); AvaloniaProperty.Register<TopLevel, IBrush>(nameof(TransparencyBackgroundFallback), Brushes.White);

Loading…
Cancel
Save