Get the index of Item selected in ListView
05:17 24 Jan 2014

I've been searching for about an hour already and couldn't find a best solution. I am migrating from VB.NET to C# Forms and to C# WPF. Never mind that... so I use this code for C# forms and it works, but not in C# WPF

 if (ListView1.SelectedItems.Count > 0)
            {
                for (lcount = 0; lcount <= ListView1.Items.Count - 1; lcount++)
                {
                    if (ListView1.Items[lcount].Selected == true)
                    {
                        var2 = lcount;
                        break;
                    }
                }
            }

this is the way I want to get the index of the item clicked in listbox. I have the error in .SELECTED

please help.

c# wpf listview indexing