|
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,33 @@ private void FileList_SelectionChanged(object sender, SelectionChangedEventArgs
|
138 | 139 | public override void StartRenameItem()
|
139 | 140 | {
|
140 | 141 | renamingItem = SelectedItem;
|
| 142 | + int extensionLength = renamingItem.FileExtension?.Length ?? 0; |
141 | 143 | GridViewItem gridViewItem = FileList.ContainerFromItem(renamingItem) as GridViewItem;
|
| 144 | + TextBox textBox = null; |
| 145 | + |
142 | 146 | // 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 |
| - int extensionLength = renamingItem.FileExtension?.Length ?? 0; |
| 147 | + if (App.AppSettings.LayoutMode == 2) |
| 148 | + { |
| 149 | + Popup popup = (gridViewItem.ContentTemplateRoot as Grid).FindName("EditPopup") as Popup; |
| 150 | + TextBlock textBlock = (gridViewItem.ContentTemplateRoot as Grid).Children[1] as TextBlock; |
| 151 | + textBox = popup.Child as TextBox; |
| 152 | + popup.IsOpen = true; |
| 153 | + } |
| 154 | + else |
| 155 | + { |
| 156 | + StackPanel stackPanel = |
| 157 | + (((gridViewItem.ContentTemplateRoot as Grid).Children[0] as StackPanel).Children[1] as Grid).Children[0] as StackPanel; |
| 158 | + TextBlock textBlock = stackPanel.Children[0] as TextBlock; |
| 159 | + textBox = stackPanel.Children[1] as TextBox; |
| 160 | + textBlock.Visibility = Visibility.Collapsed; |
| 161 | + textBox.Visibility = Visibility.Visible; |
| 162 | + } |
149 | 163 |
|
150 |
| - textBlock.Visibility = Visibility.Collapsed; |
151 |
| - textBox.Visibility = Visibility.Visible; |
152 | 164 | textBox.Focus(FocusState.Pointer);
|
153 | 165 | textBox.LostFocus += RenameTextBox_LostFocus;
|
154 | 166 | textBox.KeyDown += RenameTextBox_KeyDown;
|
155 | 167 | textBox.Select(0, renamingItem.ItemName.Length - extensionLength);
|
| 168 | + |
156 | 169 | isRenamingItem = true;
|
157 | 170 | }
|
158 | 171 |
|
@@ -219,12 +232,22 @@ private async void CommitRename(TextBox textBox)
|
219 | 232 |
|
220 | 233 | private void EndRename(TextBox textBox)
|
221 | 234 | {
|
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; |
| 235 | + if (App.AppSettings.LayoutMode == 2) |
| 236 | + { |
| 237 | + Popup popup = (textBox.Parent) as Popup; |
| 238 | + TextBlock textBlock = (popup.Parent as Grid).Children[1] as TextBlock; |
| 239 | + popup.IsOpen = false; |
| 240 | + } |
| 241 | + else |
| 242 | + { |
| 243 | + StackPanel parentPanel = textBox.Parent as StackPanel; |
| 244 | + TextBlock textBlock = parentPanel.Children[0] as TextBlock; |
| 245 | + textBox.Visibility = Visibility.Collapsed; |
| 246 | + textBlock.Visibility = Visibility.Visible; |
| 247 | + } |
| 248 | + |
226 | 249 | textBox.LostFocus -= RenameTextBox_LostFocus;
|
227 |
| - textBox.KeyDown += RenameTextBox_KeyDown; |
| 250 | + textBox.KeyDown -= RenameTextBox_KeyDown; |
228 | 251 | isRenamingItem = false;
|
229 | 252 | }
|
230 | 253 |
|
|
0 commit comments