Binding Errors in WPF / XAML


WPF doesn’t raise exceptions to notify programmer about data binding problems. If you specify an element or a property that doesn’t exist, you won’t receive any indication; instead, the data will simply fail to appear
in the target property. At first glance, this seems like a debugging nightmare. Fortunately, WPF does output trace information that details binding failures. This information appears in Visual Studio’s Output window
when you’re debugging the application. For example, if you try to bind to a nonexistent property, you’ll
see a message like this in the Output window:

Data Trigger to Inverse the value of IsChecked Property of checkbox for binding

Many times we may require to enable / disable controls in WPF on the check state of a checkbox in the window. In XAML we want to enable our control if checkbox is checked and disable if it is unchecked, this can be done very easily by using below binding


<StackPanel Orientation="Horizontal"> <CheckBox x:Name="chkHandler" Content="Enable Controls"> </CheckBox> <TextBlock Width="50" />
<TextBox x:Name="Sample" Text="Sample Text Box" 
IsEnabled="{Binding Path=IsChecked, ElementName=chkHandler}">
</TextBox> </StackPanel>

Singleton Design Pettarn - Details Explaination

What is singleton design pattern ?

Singleton design pattern allows programmer to create only one instance for a class for whole life cycle of process. In this case if developer tries to get new instance of class, he/she will get the same instance of the class which was created once.

Way of Implementation 
To implement singleton design pattern we must have to make all the constructor of the class private, so that developers can not create new instance of the class directly (Developer will not have control to create object of class).
There must be a static  method in class which will be called by developer to obtain the singleton object.

Implement Doubly Linked List with single pointer field in its Node

Hi folks,
During interview of BARC I was asked a very interesting question i.e. "Can we implement Doubly Linked List by using single pointer, How if yes?".
So here I am trying to explain you the concept of the implemetation of Doubly Linked List (Two Way Linked List) by using Single pointer.

Before going in to the concept we must understand what is Doubly or Two way Linked List.
A Doubly Linked List has following attributes:
  1. There are two pointers START & END, START contains the Address of 1st Node, and END Contains Address of Last Node.
  2. Each node of the list contains 2 pointer (NEXT, PREV) and 1 data part. NEXT contains the address of next node and PREV contains address of previous node.
  3. PREV of 1st node & NEXT of last node will contains null values.

Algorithm for Insertion of node in Two way linked list using single pointer field


TwoWayLinkedList_SinglePtr(List,Start,End,Value,Node,Curr,Prev,NextNode,N_NextNode)

Concept: In 2way linked list with single pointer, each node consists of 1 data part and 1 pointer part. The pointer part will now contain XOR of the address of Previous and Next Node. Reason behind using difference XOR is, if XORing for A and B gives C then XORing of C with A gives B and XORing of C with B gives A as result, So that it is easy to find Next Node's Address by using XOR with stored values.
List: It is actually the list in which Node is to be inserted.
START: Pointer contains the address of Starting Node.
END: Pointer contains the address of Ending Node.
Node: Node which is to be inserted.
Curr: Pointer pointing the current node, this will be used to traverse the list
Prev: Pointer pointing the Previous node
Value: Value of a Node after which new node is to be inserted
NextNode: this will contain address of the node which is next to current node
N_NextNode: this will contain address of Node which is next to NextNode.