File tree Expand file tree Collapse file tree
src/Uno.Extensions.Core.UI/Toolkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,13 @@ private UIElement? RootElement
8282
8383 private void ElementThemeChanged ( FrameworkElement sender , object args )
8484 {
85- ThemeChanged ? . Invoke ( this , GetSavedTheme ( ) ) ;
85+ _ = InternalSetThemeAsync ( sender . ActualTheme switch
86+ {
87+ ElementTheme . Default => AppTheme . System ,
88+ ElementTheme . Dark => AppTheme . Dark ,
89+ ElementTheme . Light => AppTheme . Light ,
90+ _ => AppTheme . System ,
91+ } ) ;
8692 }
8793
8894 /// <inheritdoc/>
@@ -108,10 +114,7 @@ private async Task<bool> InternalSetThemeAsync(AppTheme theme)
108114 }
109115 else
110116 {
111- return await _dispatcher . ExecuteAsync ( async ( ct ) =>
112- {
113- return InternalSetThemeOnUIThread ( theme ) ;
114- } ) ;
117+ return await _dispatcher . ExecuteAsync ( async _ => InternalSetThemeOnUIThread ( theme ) ) ;
115118 }
116119
117120 }
@@ -182,7 +185,7 @@ public async Task InitializeAsync()
182185 }
183186
184187 _initialization = new TaskCompletionSource < bool > ( ) ;
185-
188+
186189 var theme = GetSavedTheme ( ) ;
187190 var success = await InternalSetThemeAsync ( theme ) ;
188191 if ( ! success )
You can’t perform that action at this time.
0 commit comments