I have application with several datagrids and export to excel command, which gets focused datagrid as a command parameter. Is it possible to bind CommandParameter to FocusManager.FocusedElement, or do I have to set them explicity?
Thanks in advance
I have application with several datagrids and export to excel command, which gets focused datagrid as a command parameter. Is it possible to bind CommandParameter to FocusManager.FocusedElement, or do I have to set them explicity?
Thanks in advance
Yes, you can bind to the FocusedElement. Something like:
Depending on your focus scopes, you may need to change the Window to another element.
But personally, I'd setup up the command's handler to see if the parameter is null. If it is then I'd programmatically get the
FocusManager.FocusedElement
.You can also search up the visual tree as needed to the get the associated DataGrid.