Thursday, February 9, 2012

Windows Phone - Elements and Shapes (8)

Hello

Basic Shapes

Ellipse :

  • Fill - Brush for painting the interior of the ellipse
  • Stroke -  Brush for painting the ellipse outline
  • StrokeThickness - width of the stroke outline


Transforms
Transforms applied to visual elements means :
  • Shift to another location
  • Size change
  • Rotation
Transforms can be applied in Silverlight to any object that inherit UIElement : text,bitmap,movie,panel,controls.

Transform is possible using the UIElement property RenderTransform. Silverlight support few types of transform :



Sample source
BasicShapes_NK.zip
Scale transform is used. The application allows to scale an ellipse up and down using two buttons.
The scale is done relative to ScaleTransform.CenterX and  ScaleTransform.CenterY which are by default 0,0.








The Border Element
You have a TextBlock and you want to make it's border color red - problem. TextBlock does not have border, yet Silverlight has Border element which can be used in this case.


Important properties :


Sample source
TextBlockBorder.zip




TextBlock
Common properties :

  • Font :



Note that ContentProperty (see Windows Phone - XAML (7)) of TextBlock is Inlines which is a collection of content element name Inline.

Sample source
Note that Run element inherits Inline.


Running application TextBlock inside it's ContentPanel will produce





Playing Movies


Use MediaElement


Mode of Opacity
UIElement has Opacity property. It defines how transparent the element is. Value of 1 means transparent , value of 0 means full opacity i.e. you will not be able to see any element underneath it.


Brushes


SolidColorBrush :




LinearGradientBrush paints an area with linear gradient. The gradient is along a line which start at  property StartPoint and ends at property EndPoint. By default StartPoint coordinate is (0,0) and EndPoint coordinate is (1,1).

Diagonal gradient StartPoint (0,0) EndPoint (1,1)


A linearGradientBrush paints its  GradientStops along this line. GradientStop defines the location and color of a transition point in the gradient.





Vertical gardient  StartPoint (0.5,0) EndPoint (0.5,1)



Paints an area with radial gradient. It is defined by a cicle Center , GradientOrigin  and  GradientStops.






Sample source
Brushes_NK.zip
Sample uses few TextBox with brushes as background

Define Style used by all TextBox

TextBoxes with brushes as background



Running the sample will produce the following






Nathan

No comments:

Post a Comment