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}">  
     <Style.Triggers>  
       <Trigger Property="ItemsControl.AlternationIndex" Value="0">  
         <Setter Property="Background" Value="LightSkyBlue"></Setter>  
       </Trigger>  
       <Trigger Property="ItemsControl.AlternationIndex" Value="1">  
         <Setter Property="Background" Value="LightGray"></Setter>  
       </Trigger>  
       <Trigger Property="IsSelected" Value="True">  
         <Setter Property="Background" Value="Orange"/>  
       </Trigger>  
     </Style.Triggers>  
   </Style>  



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">  
   <ListView.View>  
     <GridView>  
     <GridViewColumn DisplayMemberBinding="{Binding Path=InvoiceDetailsItemId}"  
           Header="Item Id" Width="90" />  
     <GridViewColumn DisplayMemberBinding="{Binding Path=InvoiceDetailsItemName}"  
          Header="Item Name" Width="120" />  
     </GridView>  
   </ListView.View>  
 </ListView>  


enjoy...

 

WPF DateTime show in Listview and DataGrid

In our WPF application when we want to visualize the date in list or grid column. then it show us date by default with time. but we don't want to see the time. so we can control easily in xaml code of list or grid. example as:


 <ListView Height="147" HorizontalAlignment="Left" Margin="15,26,0,0" Name="lvCalList" VerticalAlignment="Top" Width="211">  
           <ListView.View>  
                <GridView>  
                     <GridViewColumn DisplayMemberBinding="{Binding Path=FromDate,StringFormat={}{0:MM/dd/yyyy}}" Header="From Date" Width="100" />  
                     <GridViewColumn DisplayMemberBinding="{Binding Path=ToDate,StringFormat={}{0:MM/dd/yyyy}}" Header="To Date" Width="105" />  
                </GridView>  
           </ListView.View>  
 </ListView>  

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. http://www.microsoft.com/download...