microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.
MIT License
367 stars 46 forks source link

DataGrid in ToolWindow cannot be set to editmode #389

Closed ccav01 closed 2 months ago

ccav01 commented 3 months ago

Create a tool window, add a datagrid. Bind it to data, works great. But I cannot figure out how to get CanUserAddRows or CanUserDeleteRows behaviors to work (both properties are set "True"). I also cannot find any method to get it out of view mode and into edit. A crippled datagrid lacking crud isn't very useful. Also, there's no means of sending actual UI controls as the "sender" parameter to emulate events. the vs:ExtensibilityUICOmmands.EventHandlers does allow calling a command, however I cannot affect anything in the UI like idk, sending a reference to the datagrid as the sender object on the event so I can call dg.BeginEdit().

matteo-prosperi commented 3 months ago

Hello, The Remote UI model used in out of process extensions is fully MVVM. So there isn't support for calling methods on the DataGrid object or returning a reference to a UI control as the "sender" of a command. AsyncCommands are supposed to receive data-bound values as parameters, not control references. The WPF data grid is not a very MVVM-friendly control as it often requires invoking methods on it in order to achieve most non trivial scenarios. For sure adding a row won't work since the WPF side of things (that runs in devenv.exe) wouldn't know how to create a new object of the type required by the data-bound collection. @tinaschrepfer, can we add a feature request in our backlog to provide a MVVM friendly data grid to extenders?

tinaschrepfer commented 2 months ago

We're moving feature suggestions and requests over to our Developer Community site so we can track them better.

This issue has been moved over to this ticket: https://developercommunity.visualstudio.com/t/VisualStudioExtensibility-Provide-a-M/10700628