Skip to content
Open
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
23 changes: 22 additions & 1 deletion 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 @@ -402,6 +403,14 @@
/// </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;
if (focused is TextBox || focused is PasswordBox || focused is RichEditBox)
{
return;
}

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

Expand All @@ -412,7 +421,19 @@

var package = new DataPackage();
package.SetText(GetSelectedClipboardContent(includeHeaders));
Clipboard.SetContent(package);

// Try/catch to prevent CLIPBRD_E_CANT_OPEN crashes.
try
{
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 @@ -586,7 +607,7 @@
}
else
{
foreach (var propertyInfo in dataType.GetProperties())

Check warning on line 610 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