-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Adjust generation for x:Bind events in x:Load context
- Loading branch information
1 parent
af614a0
commit 0938736
Showing
5 changed files
with
150 additions
and
4 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
17 changes: 17 additions & 0 deletions
17
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_xLoad_Event.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,17 @@ | ||
<Page x:Class="Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls.Binding_xLoad_Event" | ||
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 x:Name="rootGrid" | ||
x:FieldModifier="public" | ||
x:Load="{x:Bind TopLevelVisiblity, Mode=OneWay}"> | ||
<CheckBox x:Name="myCheckBox" | ||
x:FieldModifier="public" | ||
Checked="{x:Bind ViewModel.OnCheckedRaised}" | ||
Unchecked="{x:Bind ViewModel.OnUncheckedRaised}"/> | ||
</Grid> | ||
</Page> |
53 changes: 53 additions & 0 deletions
53
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/Binding_xLoad_Event.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,53 @@ | ||
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_xLoad_Event : Page | ||
{ | ||
public Binding_xLoad_Event() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
public bool TopLevelVisiblity | ||
{ | ||
get { return (bool)GetValue(TopLevelVisiblityProperty); } | ||
set { SetValue(TopLevelVisiblityProperty, value); } | ||
} | ||
|
||
// Using a DependencyProperty as the backing store for TopLevelVisiblity. This enables animation, styling, binding, etc... | ||
public static readonly DependencyProperty TopLevelVisiblityProperty = | ||
DependencyProperty.Register("TopLevelVisiblity", typeof(bool), typeof(Binding_xLoad_Event), new PropertyMetadata(false)); | ||
|
||
public Binding_xLoad_Event_ViewModel ViewModel { get; } = new Binding_xLoad_Event_ViewModel(); | ||
} | ||
|
||
public class Binding_xLoad_Event_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++; | ||
} | ||
} |
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