Cleveland Silverlight Firestarter - XAML Basics

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Cleveland Silverlight Firestarter - XAML Basics - Presentation Transcript

    1.  
    2.  
      • Similar to XML
      • Declarative Language
        • Describes the look and feel in Silverlight and WPF
        • Also use to describe workflow in Window Workflow Foundation
      < UserControl x : Class =&quot;MyTestSilverlightApp.Page&quot; xmlns =&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns : x =&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; Width =&quot;400&quot; Height =&quot;300&quot;> < Grid x : Name =&quot;LayoutRoot&quot; Background =&quot;White&quot;> </ Grid > </ UserControl > Default XAML for a New Silverlight User Control
    3. Basic XAML Syntax < TextBlock > XAML Rhymes with Camel </ TextBlock > < TextBlock Text =&quot;XAML Rhymes with Camel&quot; />
      • Simple object
      • Object with properties
    4. Grouping and Positioning
      • Objects belong to parent objects.
      • Some attributes are referenced in relation to the parent.
    5. Common Silverlight Base Layouts Canvas Stack Panel Grid
    6. Using Text
      • <TextBlock />
    7. Vector Shapes
      • <Rectangle />
      • <Ellipse />
      • <Line />
      • <Polygon />
      • <Path />
    8. Brushes
      • Determines how objects are painted
        • For painting objects (e.g. Fill)
        • For painting of lines (e.g. Stroke)
        • Supports solid color, gradient, image and video brushes
    9. Solid Colors
      • <SolidColorBrush />
        • Supports creation by name
          • 141 named colors supported (e.g. Blue, Red, Green)
          • Supports #FFFFFF or #FFFFFFFF syntax as well
    10. Linear Gradients
      • <LinearGradientBrush />
        • Start and Stop are to set angle as numbers
        • Gradient Stops are the different color points
    11. Radial Gradients
      • <RadialGradientBrush />
        • Gradient Stops are same syntax as Linear Gradient
    12. Painting with Images
      • <ImageBrush />
      <Ellipse Width=&quot;200&quot; Height=&quot;75&quot; > <Ellipse.Fill> <ImageBrush ImageSource=&quot;http://.../XBox360Logo.jpg&quot; /> </Ellipse.Fill> </Ellipse>
    13. Using Images
      • <Image />
        • Image = ImageBrush applied to Rectangle
      <Image Width=&quot;200&quot; Source=&quot;http://.../XBox360Logo.jpg&quot; />
    14. Animating with XAML
      • You can create complex Animations in XAML
        • Animations are created in XAML
        • Triggered in Code
      • Animations are made up of:
        • EventTrigger:
    15. Triggers
      • <EventTrigger />
        • Used to specify what starts an Animation
        • Properties are used to tie it to other Animation
          • RoutedEvent
            • The event that starts the triggers
            • Currently, always the Loaded event no matter what is specified
          • SourceName
            • The name of the object that has the RoutedEvent
            • Defaults to the object that the Trigger is part of
          • Actions
            • A optional list of Storyboards to fire
    16. Storyboards
      • <Storyboard />
        • Contains one or more Animations
        • Supports most of the same properties as Animations
        • Properties are used to share with all Animations
          • TargetName and TargetProperty
          • From, By and To
          • Duration
          • AutoReverse
          • RepeatBehavior
    17. Transformations
      • Used to make common changes to an object
      • Called through XAML in Object .RenderTransform tags
      • Multiple transformations can be applied by using TransformGroups
    18. Transform Types
      • Transform Types
        • <RotateTransform />
          • Rotation
        • <ScaleTransform />
          • Resizes/Stretch
        • <SkewTransform />
          • Skews
        • <TranslateTransform />
          • Moves
        • <MatrixTransform />
          • Scale, Skew and Translate Combined
    19. Animating Numbers
      • DoubleAnimation
        • Animate numeric properties
      <DoubleAnimation Storyboard.TargetName=&quot;theCircle&quot; Storyboard.TargetProperty=&quot;Width&quot; From=&quot;200&quot; To=&quot;1&quot; Duration=&quot;0:0:2&quot; AutoReverse=&quot;True&quot;/>
    20. Key Frames
      • Keyframe Animations
        • DoubleAnimationUsingKeyFrames
        • ColorAnimationUsingKeyFrames
        • PointAnimationUsingKeyFrames
      • Allows you to create an Animation using:
        • KeyFrame objects that specify values at specific times
        • Each KeyFrame contains KeyTimes and Values
    21. Types of Key Frame Animation
      • Three types of KeyFrames
        • Discrete
          • Specific value to set immediately
        • Linear
          • Animate from previous value using linear interpolation
        • Spline
          • Change value progressively using splined interpolation
    22. Animation with KeyFrames - Example ... <DoubleAnimationUsingKeyFrames Storyboard.TargetName=&quot;theCircle&quot; Storyboard.TargetProperty=&quot;Width&quot;> <DoubleAnimationUsingKeyFrames.KeyFrames> <SplineDoubleKeyFrame Value=&quot;0&quot; KeyTime=&quot;0:0:1&quot; /> <SplineDoubleKeyFrame Value=&quot;50&quot; KeyTime=&quot;0:0:2&quot; /> <SplineDoubleKeyFrame Value=&quot;150&quot; KeyTime=&quot;0:0:4&quot; /> </DoubleAnimationUsingKeyFrames.KeyFrames> </DoubleAnimationUsingKeyFrames> ...
    23. Integrating Media
      • <MediaElement />
        • Used to show media (music or video)
          • Control Video with Code
          • No Built-in Controls
      <Canvas xmlns=&quot;...&quot; xmlns:x=&quot;...&quot;> <MediaElement Source=&quot;xbox.wmv&quot; /> </Canvas>
    24. Styles in HTML
      • <style>
      • p.warning {
      • font-color: red;
      • }
      • </style>
      • <p class=“warning”>Not all fields have been filled in.</p>
    25. Styles in XAML
      • Create Style objects
      • Apply to TargetType of Style
      < Style x : Key =&quot;MainButton&quot; TargetType =&quot;Button&quot; > < Setter Property =&quot;Width&quot; Value =&quot;80&quot; /> < Setter Property =&quot;Height&quot; Value =&quot;35&quot; /> < Setter Property =&quot;FontSize&quot; Value =&quot;18&quot; /> </ Style > < Button x : Name =&quot;Button1&quot; Style =&quot;{ StaticResource MainButton }&quot; ... /> < Button x : Name =&quot;Button2&quot; Style =&quot;{ StaticResource MainButton }&quot; ... />
      • XAML File (.xaml extension)
        • Defines the look and feel
      • Code-Behind file
        • Adds functionality
    26. Code-Behind Files
        • Adds functionality, including event handling
        • Supported languages:
          • VB.NET
          • C#
          • IronRuby
          • IronPython
          • Other .NET languages
        • Support for Dynamic Languages comes in the Silverlight Dynamic Languages SDK
    27. Event Handling < Grid x : Name =&quot;LayoutRoot&quot; Background =&quot;White&quot;> < Button x : Name =&quot;button1&quot; Click =&quot;button1_Click&quot;> </ Button > </ Grid > In the code behind for this XAML file, the event handler looks like this: private void button1_Click( object sender, RoutedEventArgs e) { }
    28. XAML and Code < TextBlock x:Name= &quot;txtXAMLHint&quot; Text =&quot;XAML Rhymes with Camel&quot; Width =&quot;100&quot; /> txtXAMLHint.Width = 200; txtXAMLHint.Text = &quot; Camels should learn XAML! &quot; ; In the XAML, within a container: Accessing it in the Code-Behind:
    29. Resources
      • Silverlight Dynamic Languages SDK: http://www.codeplex.com/sdlsdk/Release/ProjectReleases.aspx?ReleaseId=17839
      • Jeff’s Series on Silverlight Layouts: http://tinyurl.com/jeffbsilverlightlayoutseries
    30. Questions on XAML Basics?

    + Sarah DutkiewiczSarah Dutkiewicz, 2 years ago

    custom

    943 views, 1 favs, 0 embeds more stats

    My slide deck from the Cleveland Silverlight Firest more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 943
      • 943 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 47
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories