Skip to main content

Posts

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 ListVie...

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>

WPF Stylist message Box

in our WPF application if we want to make our messagebox more stylist like:     we can easily do it in our application. For this we need to add a dll name WPF Extended toolkit to download from :   http://wpftoolkit.codeplex.com/ To represent the messagebox we can use: MessageBoxResult result = Microsoft.Windows.Controls.MessageBox.Show("You are welcome", "Extended WPF ToolKit MessageBox", MessageBoxButton.OKCancel, MessageBoxImage.Information); Enjoy....

WPF searching DataGrid Field From TextBox Matching data

Hi all,       Searching DataGrid Value from  TextBox is a good idea . // Hare i use a list which will retrive data from database for DataGrid ItemsSource List<EBuildingSetup> listbuildingInformation = ObjBBuildingSetup.GetAllBuildingInformation(eBuildingSetupObj); dataGrid1.ItemsSource = listbuildingInformation; //For Your button click:  for (int i = 0; i < dataGrid1.Items.Count-1; i++)             {                 EBuildingSetup objEBuildingSetup = (EBuildingSetup)dataGrid1.Items[i];                                 // Hare it is important that which field data you want to search like BuildingType in your grid              ...

WPF Contextmenu For ListView item

If we want to use context menu in WPF Listview. Then we have to done 2 steps: Bind your Listview for Contex Menu: <ListView Height="136" Background="#FFDBF3F3" BorderBrush="#FF40C01D" HorizontalAlignment="Left" Margin="6,6,0,0" Name="zonelistView" VerticalAlignment="Top" Width="722" > <ListView.ContextMenu> <ContextMenu Name="ZoneIformationList" StaysOpen="true" Background="WhiteSmoke"> <ContextMenu.BitmapEffect> <BitmapEffectGroup/> </ContextMenu.BitmapEffect> <MenuItem Header="Edit" Name="EditZoneInfoContextMenu" Click="EditZoneInfoContextMenu_Click" /> <MenuItem Header="Remove" Name="RemoveZoneInfoContextMenu" Click="RemoveZoneInfoContextMenu_Click...

WPF Multicolumn ComboBox

In WPF Multicolumn ComboBox we can easily complete it By the following procedure: Modify your Combobox maml as following: ================XAML  Binding =============== <ComboBox Height="23" HorizontalAlignment="Left" Margin="87,7,0,0" Name="ZoneBranchIDcomboBox" VerticalAlignment="Top" Width="160" > <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding ZoneBranchId}" Width="60"/> <TextBlock Text="|"/> <TextBlock Text="{Binding ZoneBranchName}" Width="60"/> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> ==========Your UI Code for Load ComboBox:========= private voi...