1
- using System ;
2
- using System . ComponentModel ;
3
- using System . Runtime . CompilerServices ;
1
+ using System . Runtime . CompilerServices ;
4
2
using System . Windows ;
5
3
using System . Windows . Threading ;
6
4
using Windows . Foundation . Metadata ;
7
5
using Windows . UI . ViewManagement ;
8
6
9
- namespace SamplesCommon
7
+ namespace ModernWpf
10
8
{
11
- public class UISettingsResources : ResourceDictionary
9
+ internal class UISettingsResources : ResourceDictionary
12
10
{
13
11
private const string UniversalApiContractName = "Windows.Foundation.UniversalApiContract" ;
14
12
private const string AutoHideScrollBarsKey = "AutoHideScrollBars" ;
@@ -17,23 +15,20 @@ public class UISettingsResources : ResourceDictionary
17
15
18
16
public UISettingsResources ( )
19
17
{
20
- if ( ! DesignerProperties . GetIsInDesignMode ( new DependencyObject ( ) ) )
18
+ if ( DesignMode . DesignModeEnabled )
21
19
{
22
- if ( Environment . OSVersion . Version . Major >= 10 )
23
- {
24
- Initialize ( ) ;
25
- }
20
+ return ;
21
+ }
22
+
23
+ if ( OSVersionHelper . IsWindows10 )
24
+ {
25
+ Initialize ( ) ;
26
26
}
27
27
}
28
28
29
29
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
30
30
private void Initialize ( )
31
31
{
32
- if ( _uiSettings != null )
33
- {
34
- return ;
35
- }
36
-
37
32
var uiSettings = new UISettings ( ) ;
38
33
39
34
if ( ApiInformation . IsApiContractPresent ( UniversalApiContractName , 4 ) )
@@ -75,11 +70,6 @@ private void InitializeForContract8(UISettings settings)
75
70
ApplyAutoHideScrollBars ( settings . AutoHideScrollBars ) ;
76
71
}
77
72
78
- private void ApplyAutoHideScrollBars ( bool value )
79
- {
80
- this [ AutoHideScrollBarsKey ] = value ;
81
- }
82
-
83
73
private void ApplyAdvancedEffectsEnabled ( bool value )
84
74
{
85
75
var key = SystemParameters . DropShadowKey ;
@@ -92,5 +82,10 @@ private void ApplyAdvancedEffectsEnabled(bool value)
92
82
this [ key ] = false ;
93
83
}
94
84
}
85
+
86
+ private void ApplyAutoHideScrollBars ( bool value )
87
+ {
88
+ this [ AutoHideScrollBarsKey ] = value ;
89
+ }
95
90
}
96
91
}
0 commit comments