Skip to content

Commit b8aa12e

Browse files
committed
implemented export feature for Uno
1 parent 19e2a0a commit b8aa12e

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/TableView.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,9 @@ internal async void ExportSelectedToCSV()
635635
return;
636636
}
637637

638-
#if WINDOWS
639638
try
640639
{
641-
var hWnd = Win32Interop.GetWindowFromWindowId(XamlRoot.ContentIslandEnvironment.AppWindowId);
642-
if (await GetStorageFile(hWnd) is not { } file)
640+
if (await GetStorageFile() is not { } file)
643641
{
644642
return;
645643
}
@@ -652,9 +650,6 @@ internal async void ExportSelectedToCSV()
652650
await tw.WriteAsync(content);
653651
}
654652
catch { }
655-
#else
656-
await Task.CompletedTask;
657-
#endif
658653
}
659654

660655
/// <summary>
@@ -679,11 +674,9 @@ internal async void ExportAllToCSV()
679674
return;
680675
}
681676

682-
#if WINDOWS
683677
try
684678
{
685-
var hWnd = Win32Interop.GetWindowFromWindowId(XamlRoot.ContentIslandEnvironment.AppWindowId);
686-
if (await GetStorageFile(hWnd) is not { } file)
679+
if (await GetStorageFile() is not { } file)
687680
{
688681
return;
689682
}
@@ -696,9 +689,6 @@ internal async void ExportAllToCSV()
696689
await tw.WriteAsync(content);
697690
}
698691
catch { }
699-
#else
700-
await Task.CompletedTask;
701-
#endif
702692
}
703693

704694
/// <summary>
@@ -713,11 +703,14 @@ protected virtual void OnExportAllContent(TableViewExportContentEventArgs args)
713703
/// <summary>
714704
/// Gets a storage file for saving the CSV.
715705
/// </summary>
716-
private static async Task<StorageFile> GetStorageFile(IntPtr hWnd)
706+
private async Task<StorageFile> GetStorageFile()
717707
{
718708
var savePicker = new FileSavePicker();
719-
InitializeWithWindow.Initialize(savePicker, hWnd);
720709
savePicker.FileTypeChoices.Add("CSV (Comma delimited)", [".csv"]);
710+
#if WINDOWS
711+
var hWnd = Win32Interop.GetWindowFromWindowId(XamlRoot.ContentIslandEnvironment.AppWindowId);
712+
InitializeWithWindow.Initialize(savePicker, hWnd);
713+
#endif
721714

722715
return await savePicker.PickSaveFileAsync();
723716
}

0 commit comments

Comments
 (0)