Saturday, May 7, 2011

WPF list view selected row colour change

For setting the background color of Listview rows in an alternate fashion (odd rows and even rows) at first create a style element :

 <Style x:Key="alternatingStyle" TargetType="{x:Type ListViewItem}">  
       <Trigger Property="ItemsControl.AlternationIndex" Value="0">  
         <Setter Property="Background" Value="LightSkyBlue"></Setter>  
       <Trigger Property="ItemsControl.AlternationIndex" Value="1">  
         <Setter Property="Background" Value="LightGray"></Setter>  
       <Trigger Property="IsSelected" Value="True">  
         <Setter Property="Background" Value="Orange"/>  

Now write this XAML code for ListView
 <ListView BorderBrush="#FFA8CC7B" Height="133" HorizontalAlignment="Left"  
    Margin="88,382,0,0"Name="lvInvDetails" VerticalAlignment="Top" Width="596"  
     ItemContainerStyle="{StaticResource alternatingStyle}" AlternationCount="2">  
     <GridViewColumn DisplayMemberBinding="{Binding Path=InvoiceDetailsItemId}"  
           Header="Item Id" Width="90" />  
     <GridViewColumn DisplayMemberBinding="{Binding Path=InvoiceDetailsItemName}"  
          Header="Item Name" Width="120" />  



vfpoledeb.1 provider is not registered on the local machine

Have u Install VFP Ole DB Provider in your System ? If No then Please Install it from following link.