Skip to content

Commit 4ae1bff

Browse files
authored
Added Cancel button in file properties (#1811)
1 parent 7a450ac commit 4ae1bff

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Files/Views/Pages/Properties.xaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,22 @@
6767
<Grid.ColumnDefinitions>
6868
<ColumnDefinition Width="*" />
6969
<ColumnDefinition Width="*" />
70+
<ColumnDefinition Width="Auto" />
7071
</Grid.ColumnDefinitions>
72+
<Button
73+
x:Name="CancelButton"
74+
x:Uid="PropertiesDialogCancelButton"
75+
Grid.Column="1"
76+
MinWidth="100"
77+
HorizontalAlignment="Right"
78+
Click="CancelButton_Click"
79+
Content="Cancel"
80+
Margin="0 0 10 0"
81+
Style="{ThemeResource ButtonRevealStyle}" />
7182
<Button
7283
x:Name="OKButton"
7384
x:Uid="PropertiesDialogOKButton"
74-
Grid.Column="1"
85+
Grid.Column="2"
7586
MinWidth="100"
7687
HorizontalAlignment="Right"
7788
Click="OKButton_Click"

Files/Views/Pages/Properties.xaml.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private async void OKButton_Click(object sender, RoutedEventArgs e)
164164
{
165165
if (contentFrame.Content is PropertiesGeneral)
166166
{
167-
(contentFrame.Content as PropertiesGeneral).SaveChanges(listedItem);
167+
await (contentFrame.Content as PropertiesGeneral).SaveChanges(listedItem);
168168
}
169169

170170
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
@@ -178,6 +178,19 @@ private async void OKButton_Click(object sender, RoutedEventArgs e)
178178
}
179179
}
180180

181+
private async void CancelButton_Click(object sender, RoutedEventArgs e)
182+
{
183+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
184+
{
185+
await ApplicationView.GetForCurrentView().TryConsolidateAsync();
186+
}
187+
else
188+
{
189+
var propertiesDialog = Interaction.FindParent<ContentDialog>(this);
190+
propertiesDialog.Hide();
191+
}
192+
}
193+
181194
private async void Page_KeyDown(object sender, KeyRoutedEventArgs e)
182195
{
183196
if (e.Key.Equals(VirtualKey.Escape))

Files/Views/Pages/PropertiesGeneral.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Windows.UI.Xaml.Navigation;
99
using Windows.ApplicationModel.Core;
1010
using Microsoft.Toolkit.Uwp.Helpers;
11+
using System.Threading.Tasks;
1112

1213
// Il modello di elemento Pagina vuota è documentato all'indirizzo https://go.microsoft.com/fwlink/?LinkId=234238
1314

@@ -64,7 +65,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
6465
base.OnNavigatedTo(e);
6566
}
6667

67-
public async void SaveChanges(ListedItem item)
68+
public async Task SaveChanges(ListedItem item)
6869
{
6970
if (ViewModel.OriginalItemName != null)
7071
{

0 commit comments

Comments
 (0)