The best approach I found is to set its style in XAML first, and then assign it in code. For example, this is how you would put borders under each row:
<ListView.Resources>
<Style x:Key="itemstyle" TargetType="{x:Type ListViewItem}">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="#BABABE" />
</Style>
</ListView.Resources>
Then, after you set the DataContext property in code, use:
myListView.ItemContainerStyle = (Style)myListView.Resources["itemstyle"];