Thursday, January 9, 2014

ButtonAnimation Example1

We will see animations in button behavior
ButtonAnimationExample1.xaml:







UI Display:
After Pressing F5,











Now click on control button.











We can see the animated font size of content of  control button.
Notes:Add a namespace named using System.Windows.Media.Animation;

Tuesday, January 7, 2014

Application command in WPF

The following commands are standard set of application commands provided by WPF.
New
Open
 Save
 SaveAs
 Print
 CancelPrint
 PrintPreview
 Stop
 Close
Undo
 Redo
Cut
Copy
Paste
Delete
Find
Replace
SelectAll
Properties
NotACommand
CorrectionList
ContextMenu
Help

We will see User Interface of some application commands.
ApplicationCommandExample1.xaml:











UI Display:










DragDrop example of Menu Items in WPF

Visual Representation:





DragDropExample1 in WPF

DragDropExample1.xaml:

DragDropExample1.xaml.cs:














UI Display:
After pressing F5,
















Enter some text (For example,DragDrop) in the textbox1 and select the text in textbox1 and drag it to textbox2.Now drop the dragged text into the textbox2.
















Now we can see the content of textbox1 in textbox2.

Happy Learning...

Sunday, January 5, 2014

Drag and Drop in WPF

It is known as general practice of data transfer or location change of a particular object in specific environment.
In technical, we can say that it is a complete process of dragging an object or control from a source to target object using mouse and drop it on the desired user interface. It is a similar to copy and paste process.
Drag and drop process involves three object as sources, target and temporary storage. Source object is the source of origin from where the object is originated to drop on the target object. DataObject is used the store data temporarily.
The drag source initiates a drag-and-drop operation by calling a static DragDrop.DodragDrop method and passing the transferred data to it.The DoDragdrop method will automatically wrap the data in a DataObject if required. The drop target is responsible for extracting the data from the DataObject.   

DragDrop Effect:
While doing DragDrop process, there are many effects that can be processed on transferred data.
In WPF, there is a DragDropEffects enumeration to specify the effect of drag-drop operation. We can define effects on source as well as target.
DragDrop Event:
Drag-Drop process supports an event driven model. Both sources and target uses a specific set of event. There are events like as GiveFeedBack and QueryContinueDrag for dragging and DragEnter, DragLeave, DragOver and Drop for dropping to process drag-drop operations.
Notes:
 1.The data that is actually being transferred typically does not have a visual representation.
2.We can write code to provide a visual representation of the data that is dragged,
3. By default, feedback is provided to the user by changing the cursor to represent the effect         that the drag-and-drop operation will have on the data, such as whether the data will be           moved or copied.
 4.The DragDropEffects values are only used to provide communication between the drag source and the       drop target regarding the effects of the drag-and-drop operation.

ViewBox:Example2

The ViewBoxExample2.xaml:








The ViewBoxExample2.xaml.cs:




















UI Display:
None:







Fill:







Uniform:

ViewBox:Example1

It is a wonderful control in WPF. It is used to scale to fit the content to the available size. It does not resize the content but transform the content in equal proportions (text and dimension).The property stretch of it is used to stretch and scale the control  to fill the available  space and has four values as Fill, None, Uniform and UniformToFill.

The ViewBoxExample1.xaml




UI Display:
After clicking F5,




Button:Inline Property

The ButtonExample3.xaml:








UI Display:
After moving mouse over button,



Button:Example2

The ButtonExample2.xaml:




UI Display:
After pressing F5,











Notes:
1    1. The property IsDefault gets or sets the value that indicates whether a Button is the default button. If a button is default button, then it can be invoked by pressing the ENTER key.
      2.When  we set the IsDefault property of a button to true, we register the button with the AccessKeyManager so that a we can invoke the button by pressing the ENTER key.

Button:Example1

The ButtonExample1.xaml:



The ButtonExample1.xaml.cs:









Notes: The method Show (String, String, MessageBoxButton, MessageBoxImage) of MessageBox class used to display a message box has a message, title bar caption, button and button icon.

UI Result:
After pressing F5












After clicking on button Click,One MessageBox appears same as mentioned below.








Copyright © Codingnodes,2014.All Rights Reserved.