'How to get all selected indices in a datagrid

I have a datagrid with the option SelectionMode = DataGridSelectionMode.Extended.

With that I can select various row.

enter image description here

I would like to know the indices of the selected rows. I am aware that I can get dtg_ExecutionTimes_PpDescriptions.SelectedItems but I am not able to retrieve the indices from that list. For example in the picture it is 1 and 3 (or 0 and 2)

Thanx



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source