C# Null-Coalescing Operator (??)

C# has an operator called Null-Coalescing Operator(??), this operator takes two operands. If left hand side operand is not null then it returns left hand side operand else it returns right hand side operands. It is very effective to assign default value to a variable.

This variable can be used with reference type as well as nullable value types. A sample code for the use of this operator is written below:

ERROR: Couldn't Find BOOTMGR while booting BackTrack via Bootable pendrive

I was trying to boot my machine with Backtrack via bootable pendrive, but unfortunately I got an error by saying

Couldn't Find BOOTMGR
boot:

No need to worry, It has just not found the boot loader. so we will have load that by the command. Just write the following command and it will be start loading

boot: /casper/vmlinuz boot=casper initrd=/casper/initrd.gz text splash vga=791    

now your machine will be start booting with backtrack via your pen drive.

ENJOY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

How to declare Hashtable or ArrayList in XAML.

To declare Hashtable or ArrayList in xaml, we need to include the System.Collection namespaces in XAML by using the below key
        xmlns:col='clr-namespace:System.Collections;assembly=mscorlib'
After declaring the namespace we can use all the class of System.Collection namespace with col: prefix

Code to Declare the HashTable in XAML:

<col:Hashtable x:Key='hash'>
       <col:DictionaryEntry x:Key='hashEntry1' Key='1' Value='a'></col:DictionaryEntry>
       <col:DictionaryEntry x:Key='hashEntry2' Key='2' Value='b'></col:DictionaryEntry>
       <col:DictionaryEntry x:Key='hashEntry3' Key='3' Value='c'></col:DictionaryEntry>
       <col:DictionaryEntry x:Key='hashEntry4' Key='4' Value='d'></col:DictionaryEntry>
</col:Hashtable>

Code to Declare the ArrayList in XAML:

Change Style of ListBoxItem when we use ItemTemplate in ListBox.

We will see how can we change background and foreground of any ListBoxItem on MouseOver or on Selection, and for ListBoxItem, ItemTemplate is being used.

Consider a ListBox in XAML, in which, ListBoxItem contains multiple Label via ItemTemplate. Now you want the background color and the text color of the Labels to be changed on Mouse Over or on Selection of the Item. To achieve this we can use following style:

Scenario to Achieve:



To change the Foreground of the text we will use following style on the Labels:

<Style TargetType="{x:Type Label}" x:Key="listBoxLabel">
  <Setter Property="Foreground" Value="Black"></Setter>
    <Style.Triggers>
      <!--Triggers for the IsSelected Property to check selection status-->
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsSelected}" Value="True">
            <Setter Property="Foreground" Value="White"></Setter>
      </DataTrigger>
      <!--Triggers for the IsMouseOver Property to check focus status-->
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsMouseOver}" Value="True">
          <Setter Property="Foreground" Value="Red"></Setter>
      </DataTrigger>
    </Style.Triggers>
 </Style>

To change the Background of the Item we will write following style for the ListBox:

What is Process?


Process: Any program running in computer is a process. So there can be multiple processes running in same computer or there can be single process running. Each and every process will have own flow of control. In sequential execution environment, all the process are executed in sequentially. In multiprocessor environment all the process are switched forth and back. 

 
Each running process has own memory range where it has executable program, data, & stack etc… , is called Address Space/Core Image. Each process is also associated with set of program registers, counter; stack pointer and Hardware registers etc.
When a process (A) is suspended temporarily by processor and later when it is resumed, it must be started from the exactly the place from where it was suspended. To do so, whole state of the process is being stored in a table called Process Table.
A process can create another process called child processes, these child processes can further create another child processes, through this we can have process hierarchy.


Process Creation:
There are 4 principal events by which a process can be created
  •   System Initialization
  •  A process creates another process
  •  A user request to create another process
  •    Initializing batch job.
Process termination:
There are the following main reason due to which a process can be terminated
  •  Normal Exit
  • Error Exit
  •  Fatal Error Exit
  • Killed by another Process.

ComboBox in WPF DataGrid's Column Header

Here, In this article, we are going to discuss, how can we add framework elements in WPF Datagrid's column header. We will add combo box in  the header. To add Combobox in the Header of DataGrid we use [GridColumn].Header tag. In the tag we can add any element directly.

<tools:DataGridTextColumn.Header>
     <ComboBox x:Name='txtCbo75P' ItemsSource='{StaticResource StringArrayResource}' SelectedIndex='0'></ComboBox>
</tools:DataGridTextColumn.Header>

Now suppose we have to create Grid as below:

In this case for the forth column rather than giving header text directly, we shall use above code

XAML

Create Nested headers in WPF DataGrid

In WPF many times we may require to render a data grid which contains multilevel headers, for example we  have columns FirstName, LastName, Address1, Address2, City, State. Now we have to render a grid in which we have these columns these columns will have group name above the column header. It means there will be another level of header above these. In our case FirstName and LastName will be under Name, and Address1, Address2, City and State Columns will be under the Address.

Sample snapshot is displayed below.


XAML: