WPF Series: Intro aka Introduction

            About 3 years ago, discussing Windows Forms with a friend, I complained that it was inconvenient to use Windows Forms to display video and music, and that it was inconvenient for him to create his own controls, as well as form toolbars.



            We did not think then that our lives would be so simplified.
    But any technology has its pros and cons. We pay for it with our time, with our projects, when about 1.5 years ago I released the simplest application for updating one game (such programs are often called “Autopatchers”), I didn’t think about the fact that there cannot be so many people who will scream not that the program has poor design or bugs, but that you need to download 20 megabytes of .Net Framework 2.0.

            Life taught me now to study the market first, because even the most beautiful and correct application may not be appreciated if the user needs to make gestures that can cause him to take his hand from pressing a bunch of unnecessary buttons in the program dialogs before he needs to spend extra pennies to run your program.

            A year ago, I heard a lot about various technologies that appeared in Net Framework 3.0. I already started writing earlier on C # / VB.Net in the context of ASP.Net and after reading the reviews of the most zealous architects, I decided to wait.

            Six months later, or rather, last spring, I listened to excellent reviews about WPF technology from my friend, he had one problem: he could not reveal 80% of the possibilities, because a normal book appeared in the summer (from those where the technology is described in detail and in a fairly accessible way), and before that it was possible to gather information only from blogs, in which, often, much was overlooked ...

            Having listened to it, and having managed experience, I first I started reading a book that was updated by this time, along with the framework to version 3.5. Much has eluded and so far continues to elude my understanding, but now there is a place to dig it: Western bloggers-programmers, having bitten the fruit of WPF, were plotted like a machine gun, and ours are starting to catch up.

    What is WPF?



            In Windows from version 3.11, there was a GDI screen output component, it was later updated, in Windows XP, if I am not mistaken, GDI + is already used.
    There were and will be many problems from using GDI + in applications, along with GDI there was a 3D output subsystem - DirectX, which existed with Windows 95. It had other problems, but it did not have a strong processor load to redraw the models.

            Microsoft seems to have matured for a long time, since they integrated WPF into Vista and Server 2008, which, it seems to me, gave a greater impetus to its use than all kinds of seminars and articles. This, by the way, gives an additional plus, because the model of redistributing applications using 3 and 3.5 frameworks is simplified.

            Actually, as I think, you already guessed that WPF uses DirectX to display applications on the user's screen. But here is the first rake, because the display of forms among users will vary in some places, because we did not conspire and did not buy 3D middle and high video card products.

            In WPF, at the moment there are 3 levels to determine how the form and other primitives on the screen will be “rendered”.

    a) Level 0: No hardware acceleration. Approximately DirectX 7.0
    b) Level 1: Partial hardware acceleration. Approximately DirectX 8.
    c) Level 2: All features are enabled. Approximately DirectX 9 and higher.


    How do you know your level or user?

    Int renderingTier = (RenderCapability.Tier >> 16);
    if(renderingTier == 0)
    {
     // 0 level
    }




            However, the developers did not limit themselves to using a different level of the presentation model, but did many more things:

    a) A new descriptive model of the form and interface in principle - XAML
    b) New Layout model: available not a linker at the compiler level,
    but a new model for incorporating one into another. Example (insert checkbox in textbox).
    c) New related controls and methods for print and media.
    d) New data binding model.
    e) New features in forms.
    f) Many other things that I have not yet learned.
    g) The ability to transfer a project to the Web almost painlessly
    (I'll talk about XBAP Rich Web Application in a couple of articles).
    h) Animation.

            Yes, calling everything everywhere forms is probably wrong, because the model consists of windows and pages, you can load pages accordingly, either in the web version, in the regular version, through the Frame component or through Canvas, for example, in WPF / E (SilverLight).


    Example of page loading: Frame.Source = new Uri ("Page1.xaml", UriKind.Relative);


            In the following article I will consider XAML. In a nutshell, I’ll say that XAML
    (eXtensible Application Markup Language) is a special descriptive language for
    documents, windows, and pages, somewhat reminiscent of a kind of mixture of XML and HTML.

    Well, a simple window example (only XAML):

    1. <Window
    2.   xmlns = "http: //schemas.microsoft.com/winfx/2006/xaml/presentation"
    3.   xmlns: x = "http: //schemas.microsoft.com/winfx/2006/xaml"
    4.   Title = "TestingWPF" Width = "310" Height = "260"
    5.   WindowStartupLocation = "CenterScreen">
    6.  
    7. <Grid>
    8.   <Grid.ColumnDefinitions>
    9.     <ColumnDefinition> </ColumnDefinition>
    10.   </Grid.ColumnDefinitions>
    11.  
    12.   <Grid.RowDefinitions>
    13.     <RowDefinition> </RowDefinition>
    14.   </Grid.RowDefinitions>
    15.  
    16.   <TextBlock Grid.Row = "0" Grid.Column = "0"> Hello World </TextBlock>
    17. </Grid>
    18. </Window>
    * This source code was highlighted with Source Code Highlighter .


            By the way, I advise you not to use Visual Studio, but XamlPadX or XamlHack, or XamlPad for testing layouts and small pieces .

    In conclusion, I would like to recommend books on WPF:

    1) WPF. Windows Presentation Foundation in .NET 3.5 with C # 2008 Examples for Professionals
    Posted by Matthew McDonald.

    Impressions:

            It was written very soundly, there are few inaccuracies in the translation, almost everything is told, minus is that it was a small circulation, and when it first appeared, I had to run and wait a month and a half.


    2) WPF. Windows Presentation Foundation in .NET 3.0 for professionals.
    Author: the same.

    Impressions:

            “In general, the book was written very well, but it seems that, nevertheless, sometimes everything is too detailed and there are inaccuracies in the translation” - this is from the words of the person (who was mentioned in the narrative earlier), who read it.

    Upd.

    Blogs

    Here are some WPF blogs:

    blogs.msdn.com/adam_nathan/
    www.drwpf.com/blog - one of the best WPF bloggers at
    www.beacosta.com/blog - all about Data Binding at WPF
    marlongrech.wordpress.com/
    joshsmithonwpf.wordpress.com/ - one of the best WPF bloggers
    work.j832.com/
    learnwpf.com/
    blog.pixelingene.com/
    sachabarber.net/ - one of the best WPF bloggers
    blogs.msdn.com/wpfsdk/
    windowsclient.net/
    www.codeplex.com/wpf/ - new official WPF controls
    wpf.netfx3.com/blogs/presentation_bloggers/ ProBook WPF

    English Books

    : Windows Presentation Foundation in .NET 3.0 by Matthew MacDonald
    Essential Windows Presentation Foundation by Chris Andersen
    WPF Unleashed by Adam Nathan

    Additional programs for working with WPF Kaxaml





    (Thanks to habrozer Vladek for help in supplementing the post and habrozer XaocCPS for reviewing it)



    I will be glad if you supplement this list, especially with books in English,
    because I have not yet studied them, but have seen them, or will make clarifications to the article. Thank!

    Also popular now: