File tree 3 files changed +91
-0
lines changed
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml
3 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ <Page x : Class =" Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls.xLoad_Back_And_Forth"
2
+ xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+ xmlns : d =" http://schemas.microsoft.com/expression/blend/2008"
4
+ xmlns : local =" using:Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls"
5
+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
6
+ xmlns : mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+ mc : Ignorable =" d" >
8
+
9
+ <NavigationView x : Name =" NavView" x : FieldModifier =" public" PaneDisplayMode =" Left" >
10
+ <NavigationView .MenuItemTemplate>
11
+ <DataTemplate
12
+ x:DataType=" local:xLoadBackAndForthVM" >
13
+ <NavigationViewItem x : Name =" nvi" IsSelected =" {x:Bind IsSelected, Mode=TwoWay}" >
14
+ <TextBlock
15
+ x:Name=" tb"
16
+ x:Load=" {x:Bind IsSelected, Mode=OneWay}"
17
+ Text=" visible" />
18
+ </NavigationViewItem >
19
+ </DataTemplate >
20
+ </NavigationView .MenuItemTemplate>
21
+ </NavigationView >
22
+ </Page >
Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using System . ComponentModel ;
3
+ using System . Runtime . CompilerServices ;
4
+ using Microsoft . UI . Xaml . Controls ;
5
+
6
+ // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
7
+
8
+ namespace Uno . UI . RuntimeTests . Tests . Windows_UI_Xaml . Controls
9
+ {
10
+ /// <summary>
11
+ /// An empty page that can be used on its own or navigated to within a Frame.
12
+ /// </summary>
13
+ public sealed partial class xLoad_Back_And_Forth : Page
14
+ {
15
+ public xLoad_Back_And_Forth ( )
16
+ {
17
+ this . InitializeComponent ( ) ;
18
+ NavView . MenuItemsSource = new List < xLoadBackAndForthVM > { new ( ) , new ( ) } ;
19
+ }
20
+ }
21
+
22
+ public class xLoadBackAndForthVM : INotifyPropertyChanged
23
+ {
24
+ private bool _isSelected ;
25
+ public event PropertyChangedEventHandler PropertyChanged ;
26
+
27
+ protected virtual void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
28
+ {
29
+ PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
30
+ }
31
+
32
+ protected bool SetField < T > ( ref T field , T value , [ CallerMemberName ] string propertyName = null )
33
+ {
34
+ if ( EqualityComparer < T > . Default . Equals ( field , value ) ) return false ;
35
+ field = value ;
36
+ OnPropertyChanged ( propertyName ) ;
37
+ return true ;
38
+ }
39
+
40
+ public bool IsSelected
41
+ {
42
+ get => _isSelected ;
43
+ set => SetField ( ref _isSelected , value ) ;
44
+ }
45
+ }
46
+ }
Original file line number Diff line number Diff line change @@ -487,6 +487,29 @@ public async Task When_xLoad_Visibility_Set()
487
487
Assert . AreEqual ( 1 , SUT . GetChildren ( ) . Count ( c => c is ElementStub ) ) ;
488
488
Assert . AreEqual ( 0 , SUT . GetChildren ( ) . Count ( c => c is Border ) ) ;
489
489
}
490
+
491
+ [ TestMethod ]
492
+ [ UnoWorkItem ( "https://github.com/unoplatform/uno/issues/18509" ) ]
493
+ public async Task When_xLoad_Set_Back_And_Forth ( )
494
+ {
495
+ var SUT = new xLoad_Back_And_Forth ( ) ;
496
+ await UITestHelper . Load ( SUT ) ;
497
+
498
+ Assert . AreEqual ( "tb" , SUT . FindFirstChild < NavigationViewItem > ( ) . FindFirstChild < ElementStub > ( ) . Name ) ;
499
+ Assert . IsNull ( SUT . FindFirstChild < NavigationViewItem > ( ) . FindFirstChild < TextBlock > ( ) ) ;
500
+
501
+ ( ( List < xLoadBackAndForthVM > ) SUT . NavView . MenuItemsSource ) [ 0 ] . IsSelected = true ;
502
+ await UITestHelper . WaitForIdle ( ) ;
503
+
504
+ Assert . AreNotEqual ( "tb" , SUT . FindFirstChild < NavigationViewItem > ( ) . FindFirstChild < ElementStub > ( ) . Name ) ;
505
+ Assert . AreEqual ( "visible" , SUT . FindFirstChild < NavigationViewItem > ( ) . FindFirstChild < TextBlock > ( ) . Text ) ;
506
+
507
+ ( ( List < xLoadBackAndForthVM > ) SUT . NavView . MenuItemsSource ) [ 0 ] . IsSelected = false ;
508
+ await UITestHelper . WaitForIdle ( ) ;
509
+
510
+ Assert . AreEqual ( "tb" , SUT . FindFirstChild < NavigationViewItem > ( ) . FindFirstChild < ElementStub > ( ) . Name ) ;
511
+ Assert . IsNull ( SUT . FindFirstChild < NavigationViewItem > ( ) . FindFirstChild < TextBlock > ( ) ) ;
512
+ }
490
513
}
491
514
}
492
515
#endif
You can’t perform that action at this time.
0 commit comments