6
6
using Windows . UI . Core ;
7
7
using Windows . UI . Xaml ;
8
8
using Windows . UI . Xaml . Controls ;
9
+ using Windows . UI . Xaml . Controls . Primitives ;
9
10
using Windows . UI . Xaml . Input ;
10
11
using Interaction = Files . Interacts . Interaction ;
11
12
@@ -138,21 +139,35 @@ private void FileList_SelectionChanged(object sender, SelectionChangedEventArgs
138
139
public override void StartRenameItem ( )
139
140
{
140
141
renamingItem = SelectedItem ;
141
- GridViewItem gridViewItem = FileList . ContainerFromItem ( renamingItem ) as GridViewItem ;
142
- // Handle layout differences between tiles browser and photo album
143
- StackPanel stackPanel = ( App . AppSettings . LayoutMode == 2 )
144
- ? ( gridViewItem . ContentTemplateRoot as Grid ) . Children [ 1 ] as StackPanel
145
- : ( ( ( gridViewItem . ContentTemplateRoot as Grid ) . Children [ 0 ] as StackPanel ) . Children [ 1 ] as Grid ) . Children [ 0 ] as StackPanel ;
146
- TextBlock textBlock = stackPanel . Children [ 0 ] as TextBlock ;
147
- TextBox textBox = stackPanel . Children [ 1 ] as TextBox ;
148
142
int extensionLength = renamingItem . FileExtension ? . Length ?? 0 ;
143
+ GridViewItem gridViewItem = FileList . ContainerFromItem ( renamingItem ) as GridViewItem ;
144
+ TextBox textBox = null ;
149
145
150
- textBlock . Visibility = Visibility . Collapsed ;
151
- textBox . Visibility = Visibility . Visible ;
146
+ // Handle layout differences between tiles browser and photo album
147
+ if ( App . AppSettings . LayoutMode == 2 )
148
+ {
149
+ Popup popup =
150
+ ( gridViewItem . ContentTemplateRoot as Grid ) . FindName ( "EditPopup" ) as Popup ;
151
+ TextBlock textBlock =
152
+ ( gridViewItem . ContentTemplateRoot as Grid ) . Children [ 1 ] as TextBlock ;
153
+ textBox = popup . Child as TextBox ;
154
+ popup . IsOpen = true ;
155
+ }
156
+ else
157
+ {
158
+ StackPanel stackPanel =
159
+ ( ( ( gridViewItem . ContentTemplateRoot as Grid ) . Children [ 0 ] as StackPanel ) . Children [ 1 ] as Grid ) . Children [ 0 ] as StackPanel ;
160
+ TextBlock textBlock = stackPanel . Children [ 0 ] as TextBlock ;
161
+ textBox = stackPanel . Children [ 1 ] as TextBox ;
162
+ textBlock . Visibility = Visibility . Collapsed ;
163
+ textBox . Visibility = Visibility . Visible ;
164
+ }
165
+
152
166
textBox . Focus ( FocusState . Pointer ) ;
153
167
textBox . LostFocus += RenameTextBox_LostFocus ;
154
168
textBox . KeyDown += RenameTextBox_KeyDown ;
155
169
textBox . Select ( 0 , renamingItem . ItemName . Length - extensionLength ) ;
170
+
156
171
isRenamingItem = true ;
157
172
}
158
173
@@ -219,12 +234,22 @@ private async void CommitRename(TextBox textBox)
219
234
220
235
private void EndRename ( TextBox textBox )
221
236
{
222
- StackPanel parentPanel = textBox . Parent as StackPanel ;
223
- TextBlock textBlock = parentPanel . Children [ 0 ] as TextBlock ;
224
- textBox . Visibility = Visibility . Collapsed ;
225
- textBlock . Visibility = Visibility . Visible ;
237
+ if ( App . AppSettings . LayoutMode == 2 )
238
+ {
239
+ Popup popup = ( textBox . Parent ) as Popup ;
240
+ TextBlock textBlock = ( popup . Parent as Grid ) . Children [ 1 ] as TextBlock ;
241
+ popup . IsOpen = false ;
242
+ }
243
+ else
244
+ {
245
+ StackPanel parentPanel = textBox . Parent as StackPanel ;
246
+ TextBlock textBlock = parentPanel . Children [ 0 ] as TextBlock ;
247
+ textBox . Visibility = Visibility . Collapsed ;
248
+ textBlock . Visibility = Visibility . Visible ;
249
+ }
250
+
226
251
textBox . LostFocus -= RenameTextBox_LostFocus ;
227
- textBox . KeyDown + = RenameTextBox_KeyDown ;
252
+ textBox . KeyDown - = RenameTextBox_KeyDown ;
228
253
isRenamingItem = false ;
229
254
}
230
255
@@ -338,4 +363,4 @@ private void AppSettings_GridViewSizeChangeRequested(object sender, EventArgs e)
338
363
_iconSize = iconSize ; // Update icon size
339
364
}
340
365
}
341
- }
366
+ }
0 commit comments