Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions src/TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -447,17 +448,44 @@
/// </summary>
internal void CopyToClipboardInternal(bool includeHeaders)
{
// Skip TableView copy logic when a cell editor already handles Ctrl+C.
// TextBox, PasswordBox, and RichEditBox all implement their own copy behavior.
var focused = FocusManager.GetFocusedElement() as FrameworkElement;

Check warning on line 453 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / Build and Deploy Job

'FocusManager.GetFocusedElement()' is obsolete: 'Use GetFocusedElement overload with XamlRoot parameter.'
if (focused is TextBox || focused is PasswordBox || focused is RichEditBox)
{
return;
}

var args = new TableViewCopyToClipboardEventArgs(includeHeaders);
OnCopyToClipboard(args);

if (args.Handled)
{
return;
}

var content = GetSelectedClipboardContent(includeHeaders);

var package = new DataPackage();
package.SetText(GetSelectedClipboardContent(includeHeaders));
Clipboard.SetContent(package);
if (string.IsNullOrWhiteSpace(content))
{
return;
}

// Try/catch to prevent CLIPBRD_E_CANT_OPEN crashes.
try
{
var package = new DataPackage();
package.SetText(content);

Clipboard.SetContent(package);
}
catch (Exception ex)
{
// Clipboard failures are normal on Windows (e.g., CLIPBRD_E_CANT_OPEN).
// Swallow to avoid crashing the application.
Debug.WriteLine(
$"TableView: Clipboard.SetContent failed: {ex}");
}
}

/// <summary>
Expand Down Expand Up @@ -633,7 +661,7 @@
}
else
{
foreach (var propertyInfo in dataType.GetProperties())

Check warning on line 664 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The return value of method 'WinUI.TableView.Extensions.ObjectExtensions.GetItemType(IEnumerable)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Check warning on line 664 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The return value of method 'WinUI.TableView.Extensions.ObjectExtensions.GetItemType(IEnumerable)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
{
var displayAttribute = propertyInfo.GetCustomAttributes().OfType<DisplayAttribute>().FirstOrDefault();
var autoGenerateField = displayAttribute?.GetAutoGenerateField();
Expand Down
Loading