@@ -29,18 +29,20 @@ public static ElementTheme ActualTheme
29
29
{
30
30
get
31
31
{
32
- return CurrentApplicationWindow ? . Dispatcher ? . HasThreadAccess == true
33
- ? CurrentApplicationWindow ? . Content is FrameworkElement rootElement
34
- && rootElement . RequestedTheme != ElementTheme . Default
35
- ? rootElement . RequestedTheme
36
- : SettingsHelper . Get < ElementTheme > ( SettingsHelper . SelectedAppTheme )
37
- : UIHelper . AwaitByTaskCompleteSource ( ( ) =>
38
- CurrentApplicationWindow ? . Dispatcher ? . AwaitableRunAsync ( ( ) =>
39
- CurrentApplicationWindow ? . Content is FrameworkElement _rootElement
40
- && _rootElement . RequestedTheme != ElementTheme . Default
41
- ? _rootElement . RequestedTheme
42
- : SettingsHelper . Get < ElementTheme > ( SettingsHelper . SelectedAppTheme ) ,
43
- CoreDispatcherPriority . High ) ) ;
32
+ return CurrentApplicationWindow == null
33
+ ? SettingsHelper . Get < ElementTheme > ( SettingsHelper . SelectedAppTheme )
34
+ : CurrentApplicationWindow . Dispatcher . HasThreadAccess
35
+ ? CurrentApplicationWindow . Content is FrameworkElement rootElement
36
+ && rootElement . RequestedTheme != ElementTheme . Default
37
+ ? rootElement . RequestedTheme
38
+ : SettingsHelper . Get < ElementTheme > ( SettingsHelper . SelectedAppTheme )
39
+ : UIHelper . AwaitByTaskCompleteSource ( ( ) =>
40
+ CurrentApplicationWindow . Dispatcher . AwaitableRunAsync ( ( ) =>
41
+ CurrentApplicationWindow . Content is FrameworkElement _rootElement
42
+ && _rootElement . RequestedTheme != ElementTheme . Default
43
+ ? _rootElement . RequestedTheme
44
+ : SettingsHelper . Get < ElementTheme > ( SettingsHelper . SelectedAppTheme ) ,
45
+ CoreDispatcherPriority . High ) ) ;
44
46
}
45
47
}
46
48
@@ -53,22 +55,24 @@ public static ElementTheme RootTheme
53
55
{
54
56
return CurrentApplicationWindow == null
55
57
? ElementTheme . Default
56
- : CurrentApplicationWindow . Dispatcher . HasThreadAccess
58
+ : CurrentApplicationWindow . Dispatcher . HasThreadAccess
57
59
? CurrentApplicationWindow . Content is FrameworkElement rootElement
58
60
? rootElement . RequestedTheme
59
61
: ElementTheme . Default
60
- : UIHelper . AwaitByTaskCompleteSource ( ( ) =>
61
- CurrentApplicationWindow . Dispatcher . AwaitableRunAsync ( ( ) =>
62
- CurrentApplicationWindow . Content is FrameworkElement _rootElement
63
- ? _rootElement . RequestedTheme
64
- : ElementTheme . Default ,
65
- CoreDispatcherPriority . High ) ) ;
62
+ : UIHelper . AwaitByTaskCompleteSource ( ( ) =>
63
+ CurrentApplicationWindow . Dispatcher . AwaitableRunAsync ( ( ) =>
64
+ CurrentApplicationWindow . Content is FrameworkElement _rootElement
65
+ ? _rootElement . RequestedTheme
66
+ : ElementTheme . Default ,
67
+ CoreDispatcherPriority . High ) ) ;
66
68
}
67
69
set
68
70
{
69
- _ = CurrentApplicationWindow ? . Dispatcher ? . AwaitableRunAsync ( ( ) =>
71
+ if ( CurrentApplicationWindow == null ) { return ; }
72
+
73
+ _ = CurrentApplicationWindow . Dispatcher . AwaitableRunAsync ( ( ) =>
70
74
{
71
- if ( CurrentApplicationWindow ? . Content is FrameworkElement rootElement )
75
+ if ( CurrentApplicationWindow . Content is FrameworkElement rootElement )
72
76
{
73
77
rootElement . RequestedTheme = value ;
74
78
}
0 commit comments