-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(textbox): A binding on the
TextBox.Text
property were always tr…
…eated as a `TwoWay` binding. Fix #3522
- Loading branch information
1 parent
f76368f
commit d2b0b80
Showing
7 changed files
with
138 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_Bindings.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Page | ||
x:Class="UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_Bindings" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<StackPanel Spacing="10" MaxWidth="275" Margin="20"> | ||
<TextBlock FontSize="18">TextBox bound with TwoWay mode</TextBlock> | ||
<TextBox Text="{Binding Text, Mode=TwoWay}" x:Name="textboxTwoWay" /> | ||
<TextBlock FontSize="18">TextBox bound with OneWay mode</TextBlock> | ||
<TextBox Text="{Binding Text, Mode=OneWay}" x:Name="textboxOneWay" /> | ||
<TextBlock FontSize="18">TextBox bound with default mode (OneWay)</TextBlock> | ||
<TextBox Text="{Binding Text}" x:Name="textboxDefault" /> | ||
<TextBlock FontSize="18">TextBlock bound on same content</TextBlock> | ||
<TextBlock Text="{Binding Text}" x:Name="textblock" /> | ||
</StackPanel> | ||
</Page> |
35 changes: 35 additions & 0 deletions
35
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_Bindings.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.ComponentModel; | ||
using Windows.UI.Xaml.Controls; | ||
using Uno.UI.Samples.Controls; | ||
|
||
namespace UITests.Windows_UI_Xaml_Controls.TextBox | ||
{ | ||
[Sample(IgnoreInSnapshotTests=true)] | ||
public sealed partial class TextBox_Bindings : Page | ||
{ | ||
public TextBox_Bindings() | ||
{ | ||
this.InitializeComponent(); | ||
DataContext = new TextBox_Bindings_Context(); | ||
} | ||
|
||
} | ||
|
||
[Windows.UI.Xaml.Data.Bindable] | ||
internal class TextBox_Bindings_Context : INotifyPropertyChanged | ||
{ | ||
private string _text; | ||
|
||
public string Text | ||
{ | ||
get => _text; | ||
set | ||
{ | ||
_text = value; | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Text))); | ||
} | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
using Uno; | ||
|
||
namespace Windows.UI.Xaml.Data | ||
{ | ||
/// <summary> | ||
/// Defines constants that indicate when a binding source is updated by its binding target in two-way binding. | ||
/// </summary> | ||
public enum UpdateSourceTrigger | ||
{ | ||
/// <summary> | ||
/// Use default behavior from the dependency property that uses the binding. In Windows Runtime, this evaluates the same as a value with PropertyChanged. | ||
/// </summary> | ||
Default = 0, | ||
/// <summary> | ||
/// The binding source is updated whenever the binding target value changes. This is detected automatically by the binding system. | ||
/// </summary> | ||
PropertyChanged = 1, | ||
/// <summary> | ||
/// The binding source is updated only when you call the BindingExpression.UpdateSource method. | ||
/// </summary> | ||
namespace Windows.UI.Xaml.Data | ||
{ | ||
/// <summary> | ||
/// Defines constants that indicate when a binding source is updated by its binding target in two-way binding. | ||
/// </summary> | ||
public enum UpdateSourceTrigger | ||
{ | ||
/// <summary> | ||
/// Use default behavior from the dependency property that uses the binding. In Windows Runtime, this evaluates the same as a value with PropertyChanged. | ||
/// </summary> | ||
Default = 0, | ||
/// <summary> | ||
/// The binding source is updated whenever the binding target value changes. This is detected automatically by the binding system. | ||
/// </summary> | ||
PropertyChanged = 1, | ||
/// <summary> | ||
/// The binding source is updated only when you call the BindingExpression.UpdateSource method. | ||
/// </summary> | ||
Explicit = 2, | ||
/// <summary> | ||
/// The binding source is updated whenever the binding target element loses focus. | ||
/// </summary> | ||
[NotImplemented] | ||
LostFocus = 3, | ||
} | ||
} | ||
|
||
/// </summary> | ||
[NotImplemented] | ||
LostFocus = 3, | ||
} | ||
} | ||