File tree Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,22 @@ private void SetUWPTitleBar()
30
30
31
31
PART_DragRegion = GetTemplateChild ( nameof ( PART_DragRegion ) ) as Grid ;
32
32
Window . Current . SetTitleBar ( PART_DragRegion ) ;
33
+
34
+ _isAutoConfigCompleted = true ;
33
35
}
34
36
}
35
37
36
38
private void ResetUWPTitleBar ( )
37
39
{
38
- CoreApplication . GetCurrentView ( ) . TitleBar . ExtendViewIntoTitleBar = false ;
39
- Window . Current . Activated -= this . Current_Activated ;
40
- SizeChanged -= this . TitleBar_SizeChanged ;
41
- CoreApplication . GetCurrentView ( ) . TitleBar . LayoutMetricsChanged -= this . TitleBar_LayoutMetricsChanged ;
42
- Window . Current . SetTitleBar ( null ) ;
40
+ // Only reset if we were the ones who configured
41
+ if ( _isAutoConfigCompleted )
42
+ {
43
+ CoreApplication . GetCurrentView ( ) . TitleBar . ExtendViewIntoTitleBar = false ;
44
+ Window . Current . Activated -= this . Current_Activated ;
45
+ SizeChanged -= this . TitleBar_SizeChanged ;
46
+ CoreApplication . GetCurrentView ( ) . TitleBar . LayoutMetricsChanged -= this . TitleBar_LayoutMetricsChanged ;
47
+ Window . Current . SetTitleBar ( null ) ;
48
+ }
43
49
}
44
50
45
51
private void Current_Activated ( object sender , Windows . UI . Core . WindowActivatedEventArgs e )
Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ private void SetWASDKTitleBar()
76
76
// Recalculate the drag region for the custom title bar
77
77
// if you explicitly defined new draggable areas.
78
78
SetDragRegionForCustomTitleBar ( ) ;
79
+
80
+ _isAutoConfigCompleted = true ;
79
81
}
80
82
}
81
83
@@ -108,11 +110,15 @@ private void ResetWASDKTitleBar()
108
110
// TO DO: Throw exception that window has not been set?
109
111
}
110
112
111
- Window . AppWindow . TitleBar . ExtendsContentIntoTitleBar = false ;
112
- this . Window . SizeChanged -= Window_SizeChanged ;
113
- this . Window . Activated -= Window_Activated ;
114
- SizeChanged -= this . TitleBar_SizeChanged ;
115
- Window . AppWindow . TitleBar . ResetToDefault ( ) ;
113
+ // Only reset if we were the ones who configured
114
+ if ( _isAutoConfigCompleted )
115
+ {
116
+ Window . AppWindow . TitleBar . ExtendsContentIntoTitleBar = false ;
117
+ this . Window . SizeChanged -= Window_SizeChanged ;
118
+ this . Window . Activated -= Window_Activated ;
119
+ SizeChanged -= this . TitleBar_SizeChanged ;
120
+ Window . AppWindow . TitleBar . ResetToDefault ( ) ;
121
+ }
116
122
}
117
123
118
124
private void Window_Activated ( object sender , WindowActivatedEventArgs args )
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ public partial class TitleBar : Control
67
67
ColumnDefinition ? PART_RightPaddingColumn ;
68
68
StackPanel ? PART_ButtonHolder ;
69
69
70
+ // Internal tracking (if AutoConfigureCustomTitleBar is on) if we've actually setup the TitleBar yet or not
71
+ // We only want to reset TitleBar configuration in app, if we're the TitleBar instance that's managing that state.
72
+ private bool _isAutoConfigCompleted = false ;
73
+
70
74
public TitleBar ( )
71
75
{
72
76
this . DefaultStyleKey = typeof ( TitleBar ) ;
You can’t perform that action at this time.
0 commit comments