Friday, March 15, 2013

Currency Format with comma's in SQL Server-2008

0 comments Posted by Rahul Kharde at 3:41 AM

Sometimes you want to have your money fields properly formatted with commas like this: 10,000,000.34


DECLARE @amount AS DECIMAL
SET @amount=11000000
SELECT CONVERT(VARCHAR,CAST(@amount AS MONEY),-1) AS 'Amount'

Output

 
Read More »

Thursday, March 14, 2013

What Is XAML?

0 comments Posted by Rahul Kharde at 4:48 AM

XAML or Extensible Application Markup Language (pronounced "zammel") is a XML based language used to create rich GUI’s.

  • XAML specifies the user interface for Silverlight or WPF application.
  • XAML is used declare controls on Silverlight or WPF Page. 
  • In simple terms XAML Page is similar to .Aspx Page in asp.net website. 
  • In .Aspx Page we use Html to form UI, while in XAML we use Xml to form UI
  • It supports both vector and bitmap images 
  • XAML is a new markup language which is used for defining UI elements and its relationships with other UI elements. 
  • XAML is a XML document which defines objects and properties and WPF loads this document in actual memory. 
  • Using XAML, you can create any kind of objects that means graphical or non-graphical. 
  • XAML is a declarative XML-based language by which you can define object and properties in XML 
  • XAML document is loaded by a XAML parser. XAML parser instantiates objects and set their properties. XAML describes objects, properties and there relation in between them. WPF parses the XAML document and instantiates the objects and creates the relation as defined by XAML.
Advantages of XAML
  • XAML code is short and clear to read
  • Separation of designer code and logic
  • Graphical design tools like Expression Blend require XAML as source.
  • The separation of XAML and UI logic allows it to clearly separate the roles of designer and developer.
Read More »

Wednesday, March 06, 2013

Attached Properties in WPF

0 comments Posted by Rahul Kharde at 8:14 AM
An attached property is a property that is declared by one control and attached to another. It allows the inclusion of additional information with a control for later use by an external source.

An attached property is a special form of dependency property that can effectively be attached to arbitrary objects. This may sound strange at first, but this mechanism has several applications in WPF.They are basically used to control layout.

Every control has its own set of intrinsic properties. Let's take an example of text box which has a specific font, text color, and text content as dictated by properties such as FontFamily, Foreground, and Text.)

Now when you place a control inside a container it gains additional features, depending on the type of container.
For example, if you place a text box inside a grid, you need to be able to choose the grid cell where it’s positioned.) These additional details are set using attached properties.

Attached properties always use a two-part name in this form:

DefiningType.
PropertyName.

This two-part naming syntax allows the XAML parser to distinguish between a normal property and an attached property. 



Read More »

What is the Triggers in WPF?

0 comments Posted by Rahul Kharde at 7:57 AM
Triggers are implemented as part of styles, and indicate a trigger condition and a new set of setters to apply when the trigger condition is met. Mouseover effects are a very common application of triggers. Triggers can fully be expressed using XAML, eliminating the need to write code for many simple effects.

There are three types of triggers in WPF:

1. Property Triggers - run when the value of a dependency property changes
2. Data Triggers - run when the value of any .NET property changes, using data binding
3. Event Triggers - run when a routed event occurs

Triggers are implement as part of a style using the <Style.Triggers> property element, and a series of <Trigger>,<DataTrigger>, or <EventTrigger> elements.

Property Triggers
Property triggers are used to monitor a DependencyProperty's value. The following example applies a glow effect to a button when the mouse pointer is over the button (IsMouseOver=true). The WPF framework automatically handles resetting the style back when the mouse pointer is moved off the button.
Read More »

WPF Interview Questions?

0 comments Posted by Rahul Kharde at 7:21 AM
What is WPF?
WPF stands for Windows Presentation Foundation. It is an application programming Interface for developing rich UI on Windows API and WINfx. WPF is introduced in .NET 3.0. By the use of WPF we can
  • Capabilities to HTML and flash.
  • Has all equivalent common user controls like buttons, check boxes   sliders etc.
  • Fixed and flow format documents 
  • 2D and 3D dimensional  graphics 
  • Multimedia 
  • Data binding

What Is XAML?

XAML (Extensible Application Markup Language) is a XML based language used to create rich GUI’s.

  • It supports both vector and bitmap images
  • XAML is a new markup language which is used for defining UI elements and its relationships with other UI elements.
  • XAML is a XML document which defines objects and properties and WPF loads this document in actual memory.
  • Using XAML, you can create any kind of objects that means graphical or non-graphical.
  • XAML is a declarative XML-based language by which you can define object and properties in XML
  • XAML document is loaded by a XAML parser. XAML parser instantiates objects and set their properties. XAML describes objects, properties and there relation in between them. WPF parses the XAML document and instantiates the objects and creates the relation as defined by XAML.

What are the core WPF assemblies?

The core WPF assemblies are,
WindowsBase.dll:- This is the core types constituting the infrastructure of WPF API.

PresentationCore.dll:- It defines numerous types constituting foundation of WPF GUI layer.

PresentationFoundation.dll:- It defines WPF control types, animation & multimedia support, data binding support and other WPF services.

  Besides these three libraries WPF also uses an unmanaged binary called milcore.dll which acts as a bridge between WPF assemblies and DirectX runtime layer.

What are the types of triggers available in WPF?

Triggers define a list of setters that are executed if the specified condition is fulfilled. WPF knows three diferent types of triggers
  • Property Triggers get active, when a property gets a specified value.
  • Event Triggers get active, when a specified event is fired.
  • Data Triggers get active, when a binding expression reaches a specified value.
What is dependency property?

WPF elements are classes with methods, properties and events. Nearly every property of a WPF element is a dependency property. Dependency properties are used with databinding, animation, resources and styles.
Only a class that derive from base class DependencyObject can include dependency properties.

What is attached property in WPF?

These are dependency properties that belong to one class but can be used in another.

Consider the below code

<Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />

Height and Width are regular properties of the Rectangle. But Canvas.Top and Canvas.
Left is dependency property as it belongs the canvas class. It’s used by the Rectangle to
specify its position within Canvas.

 

Readonly Dependency Properties

Some dependency property of WPF controls are readonly. They are often used to report the state of a control, like the IsMouseOver property. Is does not make sense to provide a setter for this value.

What is a Routed event?

In a typical WPF application, it contains many elements. These elements exist in an element tree relationship with each other. A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.
Routed events are events which navigate up or down the visual tree according to their RoutingStrategy.
You can hook up event handlers on the element that raises the event or also on other elements above or below it by using the attached event syntax: Button.Click="Button_Click". Routed events normally appear as pair. The first is a tunneling event called PreviewMouseDown and the second is the bubbling called MouseDown. They don't stop routing if the reach an event handler. To stop routing then you have to set e.Handled = true;

Tunneling The event is raised on the root element and navigates down to the visual tree until it reaches the source element or until the tunneling is stopped by marking the event as handeld. By naming convention it is called Preview... and appears before corresponding bubbling event.
Bubbling The event is raised on the source element and navigates up to the visual tree until it reaches the root element or until the bubbling is stopped by marking the event as handled. The bubbling event is raised after the tunneling event.
Direct The event is raised on the source element and must be handled on the source element itself. This behavior is the same as normal .NET events.

Which type of documents supported by WPF?
WPF supports two types of documents,
  • Fixed Format Documents
  • Flow Format Documents 
Fixed format document is like PDF. It displays contents regardless of screen resolution and size.
 
Flow format document adjust content with respect to screen resolution and size

What are the panels in WPF?

1.CANVAS - Explicitly positioning of controls
2.DOCKPANEL - Similar to windows form docking application
3.GRID - Can arrange child controls with rows and columns
4.STACKPANEL - Used to organize child controls either horizontally or vertically
5.WRAPPANEL - Can arrange child controls from left to right one after the other as long as they fit in to next line



Read More »
 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top