MIX09: Sharing Skills and Code with Silverlight & WPF

Session: Recording, Code: T87F, 59 minutes

Jeff Wilcox, Software Development Engineer, Silverlight Toolkit team, Microsoft

  • Agenda
    • Client platform vision
    • What’s shared between Silverlight and WPF?
    • Today’s Controls and Features
    • Building controls for Silverlight and WPF
    • Bringing it all together
  • Why?
    • Become a .NET expert once
    • Develop a versatile skill set
    • Not about building apps that “just work” everywhere
  • Client Platform Vision (3:12)
    • Great Platforms
      • Maximize reach with Silverlight
      • Add value with WPF
    • Shared skills, techniques, and vocabulary
    • Create once, use everywhere
      • XAML
      • .NET Code
      • Tests
    • World-class developer and designer tools
  • Current State of Microsoft client platforms, 5:14
    • Compatibility Council
    • SL3, SL Toolkit, .NET 4
    • We’re working to ensure compatibility
  • You don’t have to be a code ninja!, (6:20)
  • A Shared Demo
    • Build a SL app, and a WPF app
    • Makes a common folder
    • In 2nd project, “Add as Link”
  • What just happened?
    • Shared .NET platform
    • Shared development environment
    • Shared components
    • 100% the same source code
    • 'Can make changes in Blend to the common, and they show up in both app’s
  • Shared Client Platform
    • The Gu Technology
  • Shared .NET Framework
    • Great application platform
    • Powerful runtime
    • Great language support
    • Amazing Communities
  • Business Objects
    • Modern .NET business objects and logic
      • Collections, Generics, LINQ
    • Easy to add framework-specific value
  • Core Building Blocks, 16:21
    • XAML
    • Rich compositing
      • Shapes
      • Visual tree
    • Managed framework
      • Dependency and attached properties
      • Events
      • Control model
    • Controls
    • Layout
  • Improving compatibility, 17:50
    • Silverlight Toolkit
      • March 2009 release
        • SL2 and SL# releases available
      • SL2 development continues
    • WPF Toolkit
      • Available today
      • .NET 4
  • Silverlight toolkit
    • Fills today’s slight compatibility gap
    • Developing new controls with a rapid development cycle
    • Ships in Silverlight SDK and on CodePlex
  • Silverlight Toollkit, 20:20
    • WPF Compatible controls
      • DockPanel
      • WrapPanel
      • TreeView
    • WPF Compatible feautes
      • ImplicityStyleManager
      • LayoutTransform
    • New controls offered for Silverlight and WPF
      • Charting
      • AutoCompletedBox
  • WPF Toolkit and .NET 4, 20:38
    • Calendar

    • DatePicker

    • DataGrid

    • VisualStateManager

    • All of the SL themes will be included in WPF Toolkit

  • Building Controls for SL and WPF, 20:54
    • Summary: build for Silverlight first, and then move to WPF
    • Step 1: Basics and C# Strategy
    • Step 2: Source layout
    • Step 3: Dependency properties
    • Step 4: XAML
    • Step 5: Default styles
    • Step 6: VSM
    • Step 7 Wild hacks
  • C# Techniques
    • Partial classes
    • Extension methods and utility classes
    • Preprocessor directives
      • #if SILVERLIGHT
        • // Silverlight
      • #else
        • //WPF
      • #endif
  • Source layout, 23:05
    • Peer folders for Silverlight and WPF
    • File links and source control
    • Try to do the real work in Silverlight projects, and link from the WPF project
  • Dependency Properties, 25:55
    • Avoid WPF-specific metadata
      • Coercion
      • Read-only properties
  • XAML,31:26
    • Use WPF namespace
      • xmlns:=”https://schemas.microsoft.com/winfx/2006/xaml/presentation”
      • xmlns:x=”https://schemas.microsoft.com/winfx/2006/xaml”
    • Watch out for the Silverlight 1.0 namespace
  • Default Styles, 31:54
    • Default styles and templates for controls are selected via DefaultStyleKey property
    • Defined differently
      • WPF: Static constructor
      • Silverlight Instance constructor
  • VSM, 35:05
    • Silverlight doesn’t have triggers
    • .NET 4 / WPF get VSM
    • Add a dependency to WPF toolkit, to get VSM
    • Try to have a central state management code
  • Wild hacks, 37:45
    • Declare routed events in a partial class
      • MyControl.Wpf.CS
    • Firing routed events
      • source.OnSelectionChange (new SelectionChangedEventArgs(
        • #if SILVERLIGHT
          • SelectionChangedEvent,
        • #endif
        • removed, added));
  • Wild Hacks 2, 39:30
    • helper extension methods
    • Utility Classes
      • Abstract out application model differences
      • Abstract client platform differences
  • Putting it All Together, demo