Charles Petzold XAML. Agenda Layout and positioning Shapes, brushes, and brush resources Text, fonts, and font resources Images

  • View
    214

  • Download
    0

Embed Size (px)

Text of Charles Petzold XAML. Agenda Layout and positioning Shapes, brushes, and brush resources Text,...

  • Slide 1
  • Charles Petzold www.charlespetzold.com XAML
  • Slide 2
  • Agenda Layout and positioning Shapes, brushes, and brush resources Text, fonts, and font resources Images and writeable bitmaps UI element properties Creating XAML objects programmatically Transforms and projections Animations and animation easing GPU caching
  • Slide 3
  • Controls for positioning UI elements More in the Silverlight for Windows Phone Toolkit Layout Controls ControlDescription CanvasPositions elements using pixel coordinates GridArranges objects in rows and columns StackPanelArranges objects in a row or a column
  • Slide 4 ">
  • Slide 5
  • Stacks elements horizontally or vertically StackPanel
  • Slide 6
  • Arranges elements in rows and columns Grid
  • Slide 7
  • Absolute sizing: Width="200" Automatic sizing: Width="Auto" Column width == Width of widest object in column Proportional sizing: Sizing Rows and Columns 25% of total width 50% of total width 25% of total width
  • Slide 8 ">
  • FrameworkElement's HorizontalAlignment and VerticalAlignment properties control alignment Alignment
  • Slide 9
  • FrameworkElement's Margin property creates padding around elements Margins
  • Slide 10
  • demo Layout
  • Slide 11
  • Silverlight supports six shape types Shapes RectangleEllipsePolygon LinePolyLinePath
  • Slide 12 "> "> " title="Rectangles ">
  • Rectangles
  • Slide 13 ">
  • Paths
  • Slide 14
  • Objects used to color XAML UI elements Apply using property-element syntax Brushes BrushDescription SolidColorBrushRenders a solid color LinearGradientBrushRenders a linear gradient RadialGradientBrushRenders a radial gradient ImageBrushRenders an image
  • Slide 15 "> "> " title="Allows properties to be assigned nontrivial values Property-Element Syntax ">
  • Allows properties to be assigned nontrivial values Property-Element Syntax
  • Slide 16 "> "> " title="LinearGradientBrush ">
  • LinearGradientBrush
  • Slide 17 ">
  • RadialGradientBrush
  • Slide 18
  • Approximately 25 built-in brush resources PhoneAccentBrush and PhoneSubtleBrush PhoneBackgroundBrush and PhoneForegroundBrush PhoneChromeBrush and PhoneDisabledBrush PhoneBorderBrush and many others Colors change with theme and accent colors Complete list at http://msdn.microsoft.com/en- us/library/ff769552(v=vs.92).aspx Also in ThemeResources.xaml Stock Brush Resources
  • Slide 19
  • Stock Brush Resources in Action Dark theme Blue accent Light theme Blue accent Dark theme Orange accent
  • Slide 20 "> {StaticResource} markup extension loads the specified resource"> " title="Using Stock Brush Resources ">
  • Using Stock Brush Resources {StaticResource} markup extension loads the specified resource
  • Slide 21
  • demo Stock Brushes
  • Slide 22 Silverlight"> Silverlight"> Silverlight" title="TextBlock Silverlight">
  • TextBlock Silverlight
  • Slide 23
  • Default is Segoe WP Approx. 15 fonts provided in ROM on phones Arial, Courier New, Georgia, Times New Roman, Segoe WP, Tahoma, Trebuchet MS, Verdana, and more Complete list at http://msdn.microsoft.com/en- us/library/ff806365%28v=VS.95%29.aspx Custom fonts supported, too Fonts
  • Slide 24
  • Build TTFs into application assembly as resources Also works with ZIP files containing TTFs Reference individual fonts using syntax FontFamily="filename#fontname" Custom Fonts Silverlight
  • Slide 25
  • Built-in FontFamily resources PhoneFontFamilyNormal, PhoneFontFamilyLight, PhoneFontFamilySemiLight, PhoneFontFamilySemiBold Built-in FontSize resources PhoneFontSizeSmall, Normal, Medium, MediumLarge, Large, ExtraLarge, ExtraExtraLarge, Huge Built-in Style resources PhoneTextNormalStyle, PhoneTextAccentStyle, PhoneTextContrastStyle, and many others Combine FontFamily, FontSize, and Foreground Stock Font Resources
  • Slide 26
  • Stock Font Resources in Action PhoneTextNormalStyle PhoneTextTitle1Style PhoneTextExtraLargeStyle PhoneTextSubtleStyle PhoneTextAccentStyle
  • Slide 27
  • Opacity
  • Slide 38
  • OpacityMask...
  • Slide 39
  • From-To Animations Rectangle's Canvas.Left property varies linearly from 0 to 200 over 2 seconds
  • Slide 58 Canvas.Le"> Canvas.Left goes from 0 to 50 in first second Canvas.Left goes from 50 to 200 in second second"> Canvas.Le" title="Key-Frame Animations Canvas.Le">
  • Key-Frame Animations Canvas.Left goes from 0 to 50 in first second Canvas.Left goes from 50 to 200 in second second
  • Slide 59 // C# RectStoryBoard.Begin(); // Call Begin on Storyboard object">
  • Triggering an Animation // XAML // C# RectStoryBoard.Begin(); // Call Begin on Storyboard object
  • Slide 60 ">