The ListView is not meant to be used this way. WPF has a declarative UI that is driven by data binding. This would be the old WinForm way of doing things, but in WPF this is not the preferred way to do it, therefore it is a hack.
For example, in this scenario lets assume that each row is bound to a Database object. This object would probably have a Name property, a ConnectionString property, and a boolean IsConnected property that specified if it was connected or
not. You could then bind the ConnectButton.IsEnabled property to the Database.IsConnected property and the DisconnectButton.IsEnabled property to the Database.IsConnected property, using a converter to inverse the value. Now when you click the
ConnectedButton, through databinding this would fire the setter of the bound database object, which could contain code in its setter to actually connect, and then through databinding the DisconnectButton would autumatically enable and ConnectButton would disable.
All without writing a single line of code in the UI.
There are many different more elegant WPF preferred approaches, this was just one example. Either way, I am glad it worked for you.