Petar Tasev
6 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
24 additions and
1 deletions
-
src/Avalonia.Controls/ComboBox.cs
-
tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs
|
|
@ -86,7 +86,8 @@ namespace Avalonia.Controls |
|
|
/// Defines the <see cref="Text"/> property
|
|
|
/// Defines the <see cref="Text"/> property
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public static readonly StyledProperty<string?> TextProperty = |
|
|
public static readonly StyledProperty<string?> TextProperty = |
|
|
TextBlock.TextProperty.AddOwner<ComboBox>(new(string.Empty, BindingMode.TwoWay)); |
|
|
TextBlock.TextProperty.AddOwner<ComboBox>(new(string.Empty, BindingMode.TwoWay, |
|
|
|
|
|
enableDataValidation: true)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Defines the <see cref="SelectionBoxItemTemplate"/> property.
|
|
|
/// Defines the <see cref="SelectionBoxItemTemplate"/> property.
|
|
|
|
|
|
@ -392,6 +392,28 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public void Text_Validation() |
|
|
|
|
|
{ |
|
|
|
|
|
using (UnitTestApplication.Start(TestServices.MockThreadingInterface)) |
|
|
|
|
|
{ |
|
|
|
|
|
var target = new ComboBox |
|
|
|
|
|
{ |
|
|
|
|
|
Template = GetTemplate(), |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
target.ApplyTemplate(); |
|
|
|
|
|
target.Presenter!.ApplyTemplate(); |
|
|
|
|
|
|
|
|
|
|
|
var exception = new System.InvalidCastException("failed validation"); |
|
|
|
|
|
var textObservable = new BehaviorSubject<BindingNotification>(new BindingNotification(exception, BindingErrorType.DataValidationError)); |
|
|
|
|
|
target.Bind(ComboBox.TextProperty, textObservable); |
|
|
|
|
|
|
|
|
|
|
|
Assert.True(DataValidationErrors.GetHasErrors(target)); |
|
|
|
|
|
Assert.Equal([exception], DataValidationErrors.GetErrors(target)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Close_Window_On_Alt_F4_When_ComboBox_Is_Focus() |
|
|
public void Close_Window_On_Alt_F4_When_ComboBox_Is_Focus() |
|
|
{ |
|
|
{ |
|
|
|