Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Similar to #189 but I created this to add more detail and have it as reference for the docs. You may close this as duplicate if you see fit however.

I've managed to dynamically add TableViewTextColumn, TableViewCheckBoxColumn, and TableViewNumberColumn by using the method you showcased in the example, since TableView automatically detects the variable and creates the corresponding column for it, like CheckBoxColumn for bool. (I'm guessing Date and Time columns will also work with this by using TimeOnly and DateOnly or similar)

However, I've tried a lot of things and I can't figure out how to add these column types dynamically:

  • TableViewComboBoxColumn
  • TableViewToggleSwitchColumn

How do I dynamically add columns like this and is there any other/better way to add columns (and options for them on some occasions like for the ComboBoxColumn)?

I will make sure to include this in the docs when I begin contributing.

You must be logged in to vote

@Georgios1999 yes TableView creates date time columns for the DateOnly and TimeOnly automatically. for the ComboBox and ToggleSwitchcolumns, these columns are not generated automatically, but you can hook to the AutoGeneratingColumn event to see what type of column it will create for each property type. If you find the column inappropriate for the type, you can assign any column to the args.Column property within the event handler or can change behavior of the generated column as I do in SampleApp.
https://github.com/w-ahmad/WinUI.TableView.SampleApp/blob/41ff56cdf69f2ebc048846fb430c9a000cf2e21f/src/WinUI.TableView.SampleApp/ExampleModelColumnsHelper.cs#L7

Replies: 1 comment · 2 replies

Comment options

@Georgios1999 yes TableView creates date time columns for the DateOnly and TimeOnly automatically. for the ComboBox and ToggleSwitchcolumns, these columns are not generated automatically, but you can hook to the AutoGeneratingColumn event to see what type of column it will create for each property type. If you find the column inappropriate for the type, you can assign any column to the args.Column property within the event handler or can change behavior of the generated column as I do in SampleApp.
https://github.com/w-ahmad/WinUI.TableView.SampleApp/blob/41ff56cdf69f2ebc048846fb430c9a000cf2e21f/src/WinUI.TableView.SampleApp/ExampleModelColumnsHelper.cs#L7

You must be logged in to vote
2 replies
@Georgios1999
Comment options

Thank you for clearing that out! 🙏

I'll check it out and close this discussion once I figure it out.

@w-ahmad
Comment options

You're welcome, @Georgios1999! By the way, I think answered discussions can stay open.

Answer selected by Georgios1999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.