Friday 31 May 2013

What is WPF?

0 comments Posted by Rahul at 04:08
WPF stands for Windows Presentation Foundation. It is a Microsofts next generation UI framework to create application programming Interface for developing rich UI on Windows API and WINfx. It is part of the .NET framework 3.0 and higher versions.

WPF is compatible with
  • Multimedia 
  • Data binding
  • Animation
  • 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 
  • Documents and Multimedia into one single framework.
  • Its vector based rendering engine uses hardware acceleration of modern graphic cards.
  • This makes the UI faster, scalable and resolution independent.

Read More »

About x:Prefix

0 comments Posted by Rahul at 03:50
In the previous root element example, the prefix x: was used to map the XAML namespace http://schemas.microsoft.com/winfx/2006/xaml, which is the dedicated XAML namespace that supports XAML language constructs. This x: prefix is used for mapping this XAML namespace in the templates for projects. The XAML namespace for the XAML language contain several programming constructs that you will use very frequently in your XAML. The following is a listing of the most common x: prefix programming constructs you will use: 

x:Key: Sets a unique key for each resource in a ResourceDictionary (or similar dictionary concepts in other frameworks)

Example
<Grid>
    <Grid.Resources>
        <Style x:Name="StyleName" x:Key="StyleKey" />
    </Grid.Resources>
    <Button Style="{StaticResource StyleKey}" />
</Grid>

x:Class: Specifies the CLR namespace and class name for the class that provides code-behind for a XAML page. You must have such a class tos support code-behind per the WPF programming model, and therefore you almost always see x: mapped, even if there are no resources.

x:Name: Specifies a run-time object name for the instance that exists in run-time code after an object element is processed. In general, you will frequently use a WPF-defined equivalent property for x:Name. Such properties map specifically to a CLR backing property and are thus more convenient for application programming, where you frequently use run time code to find the named elements from initialized XAML. The most common such property is FrameworkElement.Name. You might still use x:Name when the equivalent WPF framework-level Name property is not supported in a particular type. This occurs in certain animation scenarios.

Example
<Button x:Name="okButton">OK</Button>

x:Static: Enables a reference that returns a static value that is not otherwise a XAML-compatible property. 

Example
<SolidColorBrush Color="{x:Static SystemColors.ControlColor}" />

x:Type: Constructs a Type reference based on a type name. This is used to specify attributes that take Type, such as Style.TargetType, although frequently the property has native string-to-Type conversion in such a way that the x:Type markup extension usage is optional.

Example
<Style TargetType="{x:Type Button}">
    ...
</Style>

Reference 


Read More »

Tuesday 28 May 2013

TextBlock Vs Label

0 comments Posted by Rahul at 20:51
Every WPF developer asked himself is why we have Label and TextBlock controls in WPF When it used.

TextBlock and Label both are used to display text.

TextBlock
Label
Textblock inherits from FrameworkElement
Label Inherits from System.Windows.Control
Lightweight
Heavy Weight control
Does not Supports access key
Label supports access key
TextBlock don’t have the IsEnabled Proerty
Label’s IsEnabled property returns false its text color change into gray
Simple control
More complex control
TextBlock does not have link to other controls as Target
It has a Target property

Label has an important focus handling responsibility. Its purpose is to allow you to place a caption with an access key. It has a Target property, which indicates the target of the access key. 

Example

<Label Target="{Binding ElementName=name}">User Name:</Label>
<TextBox x:Name="name" />

When to used label and TextBlock?

When you want to display text by itself use the TextBlock. The benefit is a light, performing way to display text.

When you want to associate text with another control like a TextBox use the Label control. The benefits are access keys and references to target control.



Read More »
 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to know WPF | Template by Blogger Widgets

Home | About | Top