1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
3
5
using System . Threading ;
6
+ using System . Threading . Tasks ;
4
7
using Microsoft . UI . Xaml ;
5
8
using Microsoft . UI . Xaml . Controls ;
6
9
using Microsoft . UI . Xaml . Media . Animation ;
@@ -14,7 +17,6 @@ public class StackNavigationManager
14
17
IMauiContext _mauiContext ;
15
18
Frame ? _navigationFrame ;
16
19
Action ? _pendingNavigationFinished ;
17
- ContentPresenter ? _previousContent ;
18
20
bool _connected ;
19
21
20
22
protected NavigationRootManager WindowManager => _mauiContext . GetNavigationRootManager ( ) ;
@@ -56,12 +58,6 @@ public virtual void Disconnect(IStackNavigation navigationView, Frame navigation
56
58
FirePendingNavigationFinished ( ) ;
57
59
_navigationFrame = null ;
58
60
NavigationView = null ;
59
-
60
- if ( _previousContent is not null )
61
- {
62
- _previousContent . Content = null ;
63
- _previousContent = null ;
64
- }
65
61
}
66
62
67
63
public virtual void NavigateTo ( NavigationRequest args )
@@ -170,14 +166,6 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)
170
166
VerticalAlignment = UI . Xaml . VerticalAlignment . Stretch
171
167
} ;
172
168
173
- // There's some bug in our code, or the lifecycle of ContentControl, that is causing the content to
174
- // never be removed from the parent...
175
- if ( _previousContent is not null )
176
- {
177
- _previousContent . Content = null ;
178
- _previousContent = null ;
179
- }
180
-
181
169
page . Content = presenter ;
182
170
}
183
171
else
@@ -186,15 +174,13 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)
186
174
}
187
175
188
176
// At this point if the Content isn't a ContentPresenter the user has replaced
189
- // the content so we just let them take control
177
+ // the conent so we just let them take control
190
178
if ( presenter == null || _currentPage == null )
191
179
return ;
192
180
193
- var platformPage = _currentPage . ToPlatform ( MauiContext ) ;
194
-
195
181
try
196
182
{
197
- presenter . Content = platformPage ;
183
+ presenter . Content = _currentPage . ToPlatform ( MauiContext ) ;
198
184
}
199
185
catch ( Exception )
200
186
{
@@ -204,8 +190,6 @@ void OnNavigated(object sender, UI.Xaml.Navigation.NavigationEventArgs e)
204
190
205
191
_pendingNavigationFinished = ( ) =>
206
192
{
207
- _previousContent = presenter ;
208
-
209
193
if ( presenter ? . Content is not FrameworkElement pc )
210
194
{
211
195
FireNavigationFinished ( ) ;
0 commit comments