{"id":21129505,"url":"https://github.com/guorg/gu.wpf.datagrid2d","last_synced_at":"2025-04-05T00:09:19.217Z","repository":{"id":2303673,"uuid":"38141798","full_name":"GuOrg/Gu.Wpf.DataGrid2D","owner":"GuOrg","description":"Extension methods for WPF DataGrid enabling binding to T[,]","archived":false,"fork":false,"pushed_at":"2023-12-25T16:11:30.000Z","size":1150,"stargazers_count":156,"open_issues_count":14,"forks_count":24,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T23:07:42.063Z","etag":null,"topics":["attached-properties","datagrid","wpf"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GuOrg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-27T01:24:10.000Z","updated_at":"2025-02-25T10:09:13.000Z","dependencies_parsed_at":"2023-11-06T13:44:31.884Z","dependency_job_id":"f697ea4a-7331-4d5f-88e0-6c15bc78c53e","html_url":"https://github.com/GuOrg/Gu.Wpf.DataGrid2D","commit_stats":{"total_commits":423,"total_committers":9,"mean_commits":47.0,"dds":0.2836879432624113,"last_synced_commit":"200d926ecbc3fa1e35e0e07f1469d02946a9c806"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuOrg%2FGu.Wpf.DataGrid2D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuOrg%2FGu.Wpf.DataGrid2D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuOrg%2FGu.Wpf.DataGrid2D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuOrg%2FGu.Wpf.DataGrid2D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GuOrg","download_url":"https://codeload.github.com/GuOrg/Gu.Wpf.DataGrid2D/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266564,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attached-properties","datagrid","wpf"],"created_at":"2024-11-20T05:24:22.355Z","updated_at":"2025-04-05T00:09:19.186Z","avatar_url":"https://github.com/GuOrg.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gu.Wpf.DataGrid2D\n\n[![Gitter Chat Room](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/JohanLarsson/Gu.Wpf.DataGrid2D?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) \n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![NuGet](https://img.shields.io/nuget/v/Gu.Wpf.DataGrid2D.svg)](https://www.nuget.org/packages/Gu.Wpf.DataGrid2D/)\n[![ci](https://github.com/GuOrg/Gu.Wpf.DataGrid2D/actions/workflows/ci.yml/badge.svg)](https://github.com/GuOrg/Gu.Wpf.DataGrid2D/actions/workflows/ci.yml)\n\nAttached properties for WPF DataGrid enabling binding to sources of different types. For using `DataGrid2D` you need to add `xmlns:dataGrid2D=\"http://gu.se/DataGrid2D\"` in XAML\n\n## Contents\n\n  - [ItemsSource.Array2D \u0026 Array2DTransposed](#itemssourcearray2d--array2dtransposed)\n    - [Array2D](#array2d)\n    - [Explicit columns](#explicit-columns)\n    - [With headers:](#with-headers)\n    - [Array2DTransposed](#array2dtransposed)\n  - [ItemsSource.RowsSource \u0026 ColumnsSource](#itemssourcerowssource--columnssource)\n    - [RowsSource](#rowssource)\n    - [ColumnsSource](#columnssource)\n    - [Different lengths](#different-lengths)\n  - [Selected.CellItem \u0026 Index](#selectedcellitem--index)\n  - [ItemsSource.TransposedSource \u0026 PropertySource](#itemssourcetransposedsource--propertysource)\n    - [PropertySource](#propertysource)\n    - [TransposedSource with explicit columns](#transposedsource-with-explicit-columns)\n  - [Rownumbers](#rownumbers)\n\n## ItemsSource.Array2D \u0026 Array2DTransposed\nFor binding to sources of type T[,]\n\n### Array2D\n```xml\n\u003cDataGrid HeadersVisibility=\"None\"\n          dataGrid2D:ItemsSource.Array2D=\"{Binding Data2D}\" /\u003e\n```\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/00325df.png)\n\n### Explicit columns\nColumns are referred to by `C\u003czero_based_index\u003e`\n\n```xml\n\u003cDataGrid AutoGenerateColumns=\"False\"\n          dataGrid2D:ItemsSource.Array2DTransposed=\"{Binding Data2D}\"\u003e\n    \u003cDataGrid.Columns\u003e\n        \u003cDataGridTextColumn Binding=\"{Binding C0}\" Header=\"Col 1\" /\u003e\n        \u003cDataGridTextColumn Binding=\"{Binding C1}\" Header=\"Col 2\" /\u003e\n        \u003cDataGridTextColumn Binding=\"{Binding C2}\" Header=\"Col 3\" /\u003e\n    \u003c/DataGrid.Columns\u003e\n\u003c/DataGrid\u003e\n```\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/IHvEI0c.png)\n\n### With headers:\n```xml\n\u003cDataGrid dataGrid2D:ItemsSource.Array2D=\"{Binding Data2D}\"\n          dataGrid2D:ItemsSource.ColumnHeadersSource=\"{Binding ColumnHeaders}\"\n          dataGrid2D:ItemsSource.RowHeadersSource=\"{Binding RowHeaders}\" /\u003e\n```\nRenders:  \n![With headers screenie](http://i.imgur.com/GtEOW5G.png)\n\n### Array2DTransposed\n```xml\n\u003cDataGrid dataGrid2D:ItemsSource.Array2DTransposed=\"{Binding Data2D}\" /\u003e\n```\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/N6BJqIR.png)\n\n## ItemsSource.RowsSource \u0026 ColumnsSource\nLets you bind to datasources of type `IEnumerable\u003cIEnumerable\u003e\u003e`.\nTracks collection changes.\n\n### RowsSource\n```xml\n\u003cDataGrid HeadersVisibility=\"None\"\n          dataGrid2D:ItemsSource.RowsSource=\"{Binding ListOfListsOfInts}\" /\u003e\n```\n\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/00325df.png)\n\n### ColumnsSource\n```xml\n\u003cDataGrid HeadersVisibility=\"None\"\n          dataGrid2D:ItemsSource.ColumnsSource=\"{Binding ListOfListsOfInts}\" /\u003e\n```\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/N6BJqIR.png)\n\n### Different lengths\nLimited support for different lengths. Columns with blanks are default readonly.\n\n```xml\n\u003cDataGrid dataGrid2D:ItemsSource.RowsSource=\"{Binding DifferentLengths}\" /\u003e\n```\n\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/PPlT750.png)\n\n## Selected.CellItem \u0026 Index\nLets you two-way bind the item of the currently selected cell or index (row, col).\nFor this to work these conditions must be satisfied:\n- `SelectionUnit=\"Cell\"` \n- Columns must be of type `DataGridBoundColumn`. Don't think there is a way to dig out the bound property of a `DataGridTemplateColumn`\n```xml\n\u003cDataGrid SelectionUnit=\"Cell\"\n          dataGrid2D:ItemsSource.RowsSource=\"{Binding RowVms}\"\n          dataGrid2D:Selected.CellItem=\"{Binding SelectedItem}\"\n          dataGrid2D:Selected.Index=\"{Binding Index}\" /\u003e\n``` \n\n## ItemsSource.TransposedSource \u0026 PropertySource\nSupport for transposing an itemssource, perhaps useful for property grid scenarios. Supports binding to single item or (Observable)Collection\n\n### PropertySource\nSame as TransposedSource but for a single item.\n\n\u003cDataGrid dataGrid2D:ItemsSource.PropertySource=\"{Binding Person}\"\u003e\n\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/sn8VNKG.png)\n\n### TransposedSource with explicit columns\nThe property name column is named `Name` and the following columns are named `C\u003czero_based_index\u003e`\n```xml\n\u003cDataGrid AutoGenerateColumns=\"False\" \n          dataGrid2D:ItemsSource.TransposedSource=\"{Binding Persons}\"\u003e\n    \u003cDataGrid.Columns\u003e\n        \u003cDataGridTextColumn Binding=\"{Binding Name}\" Header=\"Property\" /\u003e\n        \u003cDataGridTextColumn Binding=\"{Binding C0}\" Header=\"Value 1\" /\u003e\n        \u003cDataGridTextColumn Binding=\"{Binding C1}\" Header=\"Value 2\" /\u003e\n    \u003c/DataGrid.Columns\u003e\n\u003c/DataGrid\u003e\n```\n\nRenders:  \n![ItemsSource2D render](http://i.imgur.com/ftkeyDu.png)\n\n## Rownumbers\nConvenience attached property if you want to display rownumbers.\nSpecify the number to start fom using `StartAt` \n```xml\n\u003cDataGrid ItemsSource=\"{Binding Persons}\" dataGrid2D:Index.StartAt=\"1\"\u003e\n    \u003cDataGrid.RowHeaderStyle\u003e\n        \u003cStyle TargetType=\"{x:Type DataGridRowHeader}\"\u003e\n            \u003cSetter Property=\"Content\" Value=\"{Binding Path=(dataGrid2D:Index.OfRow), RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}\" /\u003e\n        \u003c/Style\u003e\n    \u003c/DataGrid.RowHeaderStyle\u003e\n\u003c/DataGrid\u003e\n```\nRenders:  \n![Rownumbers render](http://i.imgur.com/VkDap9E.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguorg%2Fgu.wpf.datagrid2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguorg%2Fgu.wpf.datagrid2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguorg%2Fgu.wpf.datagrid2d/lists"}