-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(xbind): Support nested expression x:Bind events
- Loading branch information
1 parent
e0da76e
commit af614a0
Showing
8 changed files
with
316 additions
and
34 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
15 changes: 15 additions & 0 deletions
15
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_Event_Nested.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_Event_Nested" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<CheckBox x:Name="myCheckBox" | ||
x:FieldModifier="public" | ||
Checked="{x:Bind ViewModel.OnCheckedRaised}" | ||
Unchecked="{x:Bind ViewModel.OnUncheckedRaised}"/> | ||
</Grid> | ||
</Page> |
49 changes: 49 additions & 0 deletions
49
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_Event_Nested.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,49 @@ | ||
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_Event_Nested : Page | ||
{ | ||
public Binding_Event_Nested() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
public Binding_Event_Nested_ViewModel ViewModel { get; } = new Binding_Event_Nested_ViewModel(); | ||
} | ||
|
||
public class Binding_Event_Nested_ViewModel | ||
{ | ||
public int CheckedRaised { get; private set; } | ||
public int UncheckedRaised { get; private set; } | ||
|
||
public void OnCheckedRaised() | ||
{ | ||
CheckedRaised++; | ||
} | ||
|
||
public void OnUncheckedRaised(object sender, RoutedEventArgs args) | ||
{ | ||
UncheckedRaised++; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
....UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_Event_Nested_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_Event_Nested_DataTemplate" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<ContentControl x:Name="root" | ||
x:FieldModifier="public"> | ||
<ContentControl.ContentTemplate> | ||
<DataTemplate x:DataType="local:Binding_Event_Nested_DataTemplate_Model"> | ||
<Grid> | ||
<CheckBox x:Name="myCheckBox" | ||
x:FieldModifier="public" | ||
Checked="{x:Bind ViewModel.OnCheckedRaised}" | ||
Unchecked="{x:Bind ViewModel.OnUncheckedRaised}"/> | ||
</Grid> | ||
</DataTemplate> | ||
</ContentControl.ContentTemplate> | ||
</ContentControl> | ||
</Page> |
52 changes: 52 additions & 0 deletions
52
....Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_Event_Nested_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,52 @@ | ||
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_Event_Nested_DataTemplate : Page | ||
{ | ||
public Binding_Event_Nested_DataTemplate() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
|
||
public class Binding_Event_Nested_DataTemplate_Model | ||
{ | ||
public Binding_Event_Nested_DataTemplate_ViewModel ViewModel { get; } = new Binding_Event_Nested_DataTemplate_ViewModel(); | ||
} | ||
|
||
public class Binding_Event_Nested_DataTemplate_ViewModel | ||
{ | ||
public int CheckedRaised { get; private set; } | ||
public int UncheckedRaised { get; private set; } | ||
|
||
internal void OnCheckedRaised() | ||
{ | ||
CheckedRaised++; | ||
} | ||
|
||
internal void OnUncheckedRaised(object sender, RoutedEventArgs args) | ||
{ | ||
UncheckedRaised++; | ||
} | ||
} | ||
} |
Oops, something went wrong.