1 / 29

.NET Framework 3.0 - Presentation

.NET Framework 3.0 - Presentation. About Me. Patrik Löwendahl C# MVP Certified Vista Touchdown Trainer Instructor @ Cornerstone Blog @ www.lowendahl.net Cornerstone Swedens largest CPLS 4 Course centers, Stockholm, Malmoe, Gothenburg, Sundsvall. Agenda. WPF Solutions WPF Data Binding

lbeverly
Download Presentation

.NET Framework 3.0 - Presentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .NET Framework 3.0 - Presentation

  2. About Me • Patrik Löwendahl • C# MVP • Certified Vista Touchdown Trainer • Instructor @ Cornerstone • Blog @ www.lowendahl.net • Cornerstone • Swedens largest CPLS • 4 Course centers, Stockholm, Malmoe, Gothenburg, Sundsvall.

  3. Agenda • WPF Solutions • WPF Data Binding • WPF Interop with Windows Forms • WPF/e

  4. WPF Solutions • Overview • Styles and Resources • 3D Rendering

  5. WPF Vision • Integrated, vector-based composition engine • Utilizing the power of the PC throughout the graphics stack • Unified approach to UI, Documents, and Media • Integration as part of development and experience • Declarative programming • Bringing designers directly into application development • Ease of deployment • Allowing administrators to deploy and manage applications securely

  6. WPF Controls • Controls are ”lookless” • Behaviour and rendering is separated • Based on basic shapes • Includes Actions, Triggers, Styling

  7. WPF Styles • Styles sets up control rendering • Microsoft delivers Expression Suite to create styles • Styles can be shareable throughout the application • Styles can be dynamic

  8. WPF Data Binding • Declarative • Shared data sources • Master / Detail Binding

  9. WPF Databinding model Control • Target • Any property, any element • Source • CLR Object • WPF Element • ADO.NET • XML • Dynamic • INotifyPropertyChanged, DependencyProperty or PropertyDescriptor • Multiple models • One Time • One Way • Two Way • Value Converter Property Binding “Data Item” Property

  10. Declarative DataBinding <Image Source="truck.png" Canvas.Left= "{Binding Path=Value, ElementID=horzPos}" /> <Slider Orientation= "Horizontal" Name="horzPos" Value="40"/> {Binding Path=Value, ElementName=horzPos}

  11. Static Data Sources • Add to resource dictionary • Named source objects • Point to lists or methods • Use with resource binding • {StaticResourcetheCars} <Window> <Window.Resources> <ObjectDataProvider x:Key=“theCars" ObjectType=" {x:Type Cars}" /> </Window.Resources> ... <TextBlock TextContent="{Binding Path=Bar, Source={StaticResource myData} }" />

  12. Share Common Source DataContext= {Binding Source={StaticResource myData}} StackPanel HorizontalSlider Value= {Binding Path=XPos, Source={StaticResource myData}} Value= {Binding Path=XPos} Image Canvas.Left= {Binding Path=XPos, Source={StaticResource myData}} Canvas.Left= {Binding Path=XPos}

  13. DataTemplate Using DataTemplates class Car { string Image {get;set} string Model {get;set} } <DataTemplate x:Key="carTemplate"> <Border BorderBrush="Blue" BorderThickness="2" Background="LightGray" Margin="10" Padding="15,15,15,5"> <StackPanel> <Image HorizontalAlignment="Center" Source="{Binding Path=Image}" /> <Border HorizontalAlignment="Center" BorderBrush="Navy" Background="#DDF" BorderThickness="1" Margin="10" Padding="3"> <TextBlock FontSize="18" Text="{Binding Path=Model}" /> </Border> </StackPanel> </Border> </DataTemplate>

  14. Master Details Binding Use ItemsControl (e.g. ListBox) as master Set IsSynchronizedWithCurrentItem="True" Other bindings on same source will follow master

  15. WPF Interop with Windows Forms • How do I get from here to there? • Do I rewrite everything? • Too much code to rewrite • Existing plug-ins • Existing controls • Existing documents

  16. WPF Interop with Windows Forms • How do I get from here to there? • Do I rewrite everything? • Too much code to rewrite • Existing plug-ins • Existing controls • Existing documents

  17. Using existing code with WPF • Package into a control • Use control inside WPF Content • Look and feel issues

  18. Mixed Applictaion Considerations • Lower Initial Cost • Potential higher TCO • ”Airspace”

  19. ”Airspace” File Edit View Help File Edit View Help • One Pixel One Technology Win32 WPF Win32 WPF DirectX DirectX

  20. ”Airspace” File Edit View Help File Edit View Help Win32 • One Pixel One Technology Win32 WPF WPF DirectX DirectX

  21. Interop best practices Chrome Canvas

  22. Show me the Code private void WindowLoaded(object sender, EventArgs e) { WindowsFormsHost host = new WindowsFormsHost(); host.Height = new Length(120); host.Width = new Length(150); swf.Control child = new UserControl1(); child.Dock = swf.DockStyle.None; host.AddChild(child); border.Child = host; }

  23. WPF/e • Subset of XAML focused on interactive content • WPF/E provides execution environments for the XAML subset • Browsers: IE, Firefox, Safaric, Netscape, others... • Supported trough browser plug-ins • OS: W2K, XP, Vista and MAC OsX • Devices: Windows Mobile, etc

  24. WPF/E Architecture

  25. Increased developer productivity • Integrated Platform for UI, Text, and Media • Declarative Programming (XAML) • Brings Designers Into the Application • Development Process • Tools for Designers: Microsoft Expression • Tools for Developers: Visual Studio • 3rd Party Support: Mobiform, Electric Rain

  26. WPF/E Programming model • XAML and JavaScript in a web page • Access "WPF/E" via JavaScript • Support inline and external XAML/script • XAML and .NET Framework code • "WPF/E" hosts a x-platform .NET runtime • Code (C#) is compiled into an intermediate language (IL) • IL is run in a secure and “managed” environment • "WPF/E" loads external package containing IL and XAML

  27. External package <html> <body> <object/embed id=“wpfehost” size=“…”> <param name=“source” value=“default.wpfe”/> <param name=“startuppage” value=“default.xaml”/> </…> </body> </html> • default.wpfe contains: • - default.xaml (compressed) • - It may also contain: • - Other XAML files • - XAML and script files • -Resources (images, media, fonts, others)

  28. Programming model sample.xaml: <Page Name=“p1”> <Button Name=“b1”>Turn Red</Button> </Page> sample.cs (becomes sample.il): b1.Click += new EventHandler(Button1_Click); void Button1_Click(object sender, EventArgs e) { p1.Background = Brushes.Red; }

More Related