Skip to content

Make TableViewTemplateColumn use ClipboardContentBinding#355

Open
Mangepange wants to merge 2 commits intow-ahmad:mainfrom
Mangepange:bugfix_347_copy_templatecolumn
Open

Make TableViewTemplateColumn use ClipboardContentBinding#355
Mangepange wants to merge 2 commits intow-ahmad:mainfrom
Mangepange:bugfix_347_copy_templatecolumn

Conversation

@Mangepange
Copy link
Copy Markdown

This is a fix for #347

TableViewTemplateColumn now gets to use the ClipboardContentBinding.
If this property is not set, the result is as previous, the clipboard and export is empty for these columns. (If it weren't for the new "return null" in TableViewColumn.GetClipboardContent, the cell would return the datacontext type name)

I also fixed the same issue when exporting. Since there's no Binding property on template columns, I figured that a reasonable behavior would be to use the ClipboardContentBinding during export as well.

@w-ahmad w-ahmad linked an issue Apr 30, 2026 that may be closed by this pull request
}

/// <inheritdoc/>
public override object? GetCellContent(object? dataItem)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could cause some confusion, so maybe we should add a property to enable or disable this behavior.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean for the export? If not providing a value for the ClipboardContentBinding I believe everything works as before. Both copying and exporting. But maybe I could add an ExportContentBinding property to the template column to separate them if you think that is better?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that GetCellContent is also used for filtering and sorting, so yeah, probably confusing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new property to the TableViewTemplateColumn, OperationContentBinding. If set, it's used to provide cell content to sorting, filtering, exporting.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good approach. Maybe we should move it to the base column so the other columns can use it as well.

…option to use a binding for sorting, exporting, filtering

if (_funcCompiledPropertyPath is null && !string.IsNullOrWhiteSpace(ClipboardContentBindingPropertyPath))
_funcCompiledPropertyPath = dataItem.GetFuncCompiledPropertyPath(ClipboardContentBindingPropertyPath!);
if (_funcCompiledPropertyPath is null)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would cause null values to be returned if the PropertyPath is null. For example, if the TableView is bound to a collection like List<int>, the column binding wouldn’t have any path, so with this change, the value would always be null when it shouldn’t be. Let's revert this change.

}

/// <inheritdoc/>
public override object? GetCellContent(object? dataItem)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good approach. Maybe we should move it to the base column so the other columns can use it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot copy value of TableViewTemplateColumn

2 participants