File tree Expand file tree Collapse file tree
src/CodeBreaker.Avalonia/CodeBreaker.Avalonia/Views/Pages Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22using Avalonia . Interactivity ;
33using Codebreaker . ViewModels ;
44using Codebreaker . ViewModels . Contracts . Services ;
5+ using CommunityToolkit . Mvvm . Messaging ;
56
67namespace CodeBreaker . Avalonia . Views . Pages ;
78
8- public partial class GamePage : UserControl
9+ public partial class GamePage : UserControl , IRecipient < GameMoveMessage >
910{
1011 private readonly INavigationService _navigationService ;
1112
1213 public GamePage ( )
1314 {
1415 DataContext = App . Current . GetService < GamePageViewModel > ( ) ;
15- InitializeComponent ( ) ;
1616 _navigationService = App . Current . GetService < INavigationService > ( ) ;
17+ InitializeComponent ( ) ;
18+ WeakReferenceMessenger . Default . Register ( this ) ;
19+ }
20+
21+ protected override void OnUnloaded ( RoutedEventArgs e )
22+ {
23+ WeakReferenceMessenger . Default . UnregisterAll ( this ) ;
1724 }
1825
1926 public GamePageViewModel ViewModel => ( GamePageViewModel ) DataContext ! ;
2027
28+ public void Receive ( GameMoveMessage message )
29+ {
30+ if ( message . GameMoveValue is not GameMoveValue . Completed )
31+ return ;
32+
33+ pegScrollViewer . UpdateLayout ( ) ;
34+ pegScrollViewer . ScrollToEnd ( ) ;
35+ }
36+
2137 private void ToTestPageButtonClicked ( object ? sender , RoutedEventArgs e )
2238 {
2339 _navigationService . NavigateToAsync ( "TestPage" ) ;
You can’t perform that action at this time.
0 commit comments