Tag: Silverlight

Creating Button in XAML in WPF and Windows Store App

Below is a sample Xaml code that is used to create a button in WPF and Windows Store App. <Button xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” Content=”Abundantcode Button”/> The Button can also be created in the code behind of your Xaml page in C# . You would generally see the difference in the namespace based on the UI framework. For example , if you want to create a button in…

Creating an Animation in XAML and Silverlight

Below is a sample code snippet that demonstrates how to create a simple animation in XAML and Silverlight Creating an Animation in XAML and Silverlight <Grid x:Name=”LayoutRoot” Background=”White”> <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Width=”400″ Height=”300″ > <Canvas.Background> <SolidColorBrush Color=”Yellow”/> </Canvas.Background> <Rectangle Width=”190″ Height=”160″ Fill=”Red” Stroke=”Green” Canvas.Left=”0″ Canvas.Top=”50″ RenderTransformOrigin=”0,0″ > <Rectangle.RenderTransform> <TransformGroup> <RotateTransform x:Name=”RotateTransform” Angle=”0″/> <ScaleTransform x:Name=”ScaleTransform” ScaleX=”0″ ScaleY=”0″ /> </TransformGroup> </Rectangle.RenderTransform> </Rectangle> </Canvas> <Grid.Triggers> <EventTrigger RoutedEvent=”Grid.Loaded”>…

Rectangle and MatrixTransform example in Silverlight and XAML

Below is a sample code snippet demonstrating how to use the MatrixTransform with the Rectangle control in Silverlight and XAML. Rectangle and MatrixTransform example in Silverlight and XAML <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Width=”400″ Height=”300″ > <Canvas.Background> <SolidColorBrush Color=”Yellow”/> </Canvas.Background> <Rectangle Width=”190″ Height=”160″ Fill=”Red” Stroke=”Green” Canvas.Left=”0″ Canvas.Top=”50″ RenderTransformOrigin=”0,0″ > <Rectangle.RenderTransform> <MatrixTransform> <MatrixTransform.Matrix> <Matrix M11=”0.5″ M12=”0.5″ OffsetX=”1 ” M21=”0″ M22=”1″ OffsetY=”0″ /> </MatrixTransform.Matrix> </MatrixTransform> </Rectangle.RenderTransform> </Rectangle> </Canvas>

Rectangle and SkewTransform example in Silverlight and XAML

Below is a sample code snippet demonstrating how to use the SkewTransform with the Rectangle control in Silverlight and XAML. Rectangle and SkewTransform example in Silverlight and XAML <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Width=”400″ Height=”300″ > <Canvas.Background> <SolidColorBrush Color=”Yellow”/> </Canvas.Background> <Rectangle Width=”190″ Height=”160″ Fill=”Red” Stroke=”Green” Canvas.Left=”0″ Canvas.Top=”50″ RenderTransformOrigin=”0,0″ > <Rectangle.RenderTransform> <SkewTransform AngleX=”45″ /> </Rectangle.RenderTransform> </Rectangle> </Canvas>

Rectangle and ScaleTransform example in Silverlight and XAML

Below is a sample code snippet demonstrating how to use the ScaleTransform with the Rectangle control in Silverlight and XAML. Rectangle and ScaleTransform example in Silverlight and XAML <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Width=”400″ Height=”300″ > <Canvas.Background> <SolidColorBrush Color=”Yellow”/> </Canvas.Background> <Rectangle Width=”190″ Height=”160″ Fill=”Red” Stroke=”Green” Canvas.Left=”200″ Canvas.Top=”50″ RenderTransformOrigin=”0,0″ > <Rectangle.RenderTransform> <ScaleTransform ScaleX=”2″ ScaleY=”2″/> </Rectangle.RenderTransform> </Rectangle> </Canvas>

Rectangle and TranslateTransform example in Silverlight and XAML

Below is a sample code snippet demonstrating how to use the TranslateTransform with the Rectangle control in Silverlight and XAML. Rectangle and TranslateTransform example in Silverlight and XAML <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Width=”400″ Height=”300″ > <Canvas.Background> <SolidColorBrush Color=”Yellow”/> </Canvas.Background> <Rectangle Width=”190″ Height=”160″ Fill=”Red” Stroke=”Green” Canvas.Left=”200″ Canvas.Top=”50″ RenderTransformOrigin=”0,0″ > <Rectangle.RenderTransform> <TranslateTransform X=”100″ Y=”100″/> </Rectangle.RenderTransform> </Rectangle> </Canvas>

Rectangle and RotateTransform example in Silverlight and XAML

Below is a sample code snippet demonstrating how to use the RotateTransform with the Recangle control in Silverlight and XAML. Rectangle and RotateTransform example in Silverlight and XAML <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Width=”400″ Height=”300″ > <Canvas.Background> <SolidColorBrush Color=”Yellow”/> </Canvas.Background> <Rectangle Width=”190″ Height=”160″ Fill=”Red” Stroke=”Green” Canvas.Left=”200″ Canvas.Top=”50″ RenderTransformOrigin=”0,0″ > <Rectangle.RenderTransform> <RotateTransform Angle=”45″/> </Rectangle.RenderTransform> </Rectangle> </Canvas>

How to Add Comment in XAML and Silverlight?

You can add comment in XAML using the following format <!– Your Comment –> How to Add Comment in XAML and Silverlight? Sample code snippet demonstrating the inclusion of the comments in XAML page. <!–This Section is a Grid Layout–> <Grid x:Name=”LayoutRoot” Background=”White”> <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Background=”Green” Width=”400″ Height=”300″ > <Ellipse x:Name=”ACEllipse” Fill=”Red” Stroke=”Pink” Width=”200″ Height=”200″/> </Canvas> </Grid>

Creating a Canvas Control with Children in Silverlight using XAML

Below is a sample code snippet for creating a Canvas Control with Children in Silverlight 5 using XAML. Canvas Control with Children in Silverlight 5 using XAML <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Background=”Green” Width=”400″ Height=”300″ > <Ellipse x:Name=”ACEllipse” Fill=”Red” Stroke=”Pink” Width=”200″ Height=”200″/> </Canvas>

Creating a Simple Canvas in Silverlight using XAML

Below is a sample code snippet for creating a canvas control in Silverlight 5 using XAML. Creating a Simple Canvas in Silverlight using XAML <Canvas x:Name=”ACCanvas” xmlns=”http://schemas.microsoft.com/client/2007″ xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Background=”Green” Width=”400″ Height=”300″ > </Canvas>

Liked this content?. Please spread the word :)