-
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(xbind): Possible invalid type cast in two-way mode
- Loading branch information
1 parent
d3c70c3
commit b952235
Showing
6 changed files
with
175 additions
and
3 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
15 changes: 15 additions & 0 deletions
15
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_TypeMismatch.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,15 @@ | ||
<Page x:Class="Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls.Binding_TypeMismatch" | ||
xmlns:sys="using:System" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<Slider x:Name="mySlider" | ||
x:FieldModifier="public" | ||
Value="{x:Bind MyInteger, Mode=TwoWay}"/> | ||
</Grid> | ||
</Page> |
45 changes: 45 additions & 0 deletions
45
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_TypeMismatch.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,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class Binding_TypeMismatch : Page, System.ComponentModel.INotifyPropertyChanged | ||
{ | ||
private int _myProperty; | ||
|
||
public Binding_TypeMismatch() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; | ||
|
||
public int MyInteger | ||
{ | ||
get => _myProperty; | ||
set | ||
{ | ||
_myProperty = value; | ||
PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(MyInteger))); | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
....UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_TypeMismatch_DataTemplate.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,22 @@ | ||
<Page x:Class="Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls.Binding_TypeMismatch_DataTemplate" | ||
xmlns:sys="using:System" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<ContentControl x:Name="root" | ||
x:FieldModifier="public"> | ||
<ContentControl.ContentTemplate> | ||
<DataTemplate x:DataType="local:Binding_TypeMismatch_DataTemplate_Data"> | ||
<Slider x:Name="mySlider" | ||
x:FieldModifier="public" | ||
Value="{x:Bind MyInteger, Mode=TwoWay}"/> | ||
</DataTemplate> | ||
</ContentControl.ContentTemplate> | ||
</ContentControl> | ||
</Grid> | ||
</Page> |
48 changes: 48 additions & 0 deletions
48
....Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_TypeMismatch_DataTemplate.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,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class Binding_TypeMismatch_DataTemplate : Page | ||
{ | ||
|
||
public Binding_TypeMismatch_DataTemplate() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
|
||
public class Binding_TypeMismatch_DataTemplate_Data : System.ComponentModel.INotifyPropertyChanged | ||
{ | ||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; | ||
|
||
private int _myProperty; | ||
|
||
public int MyInteger | ||
{ | ||
get => _myProperty; | ||
set | ||
{ | ||
_myProperty = value; | ||
PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(MyInteger))); | ||
} | ||
} | ||
} | ||
} |
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