📜 ⬆️ ⬇️

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 output video and music, and a friend that he was uncomfortable creating his controls, as well as forming toolbars.



We did not think then that life would be so simplified for us.
But any technology has its pros and cons. We pay for it with our time, with our projects, when I released the simplest application for updating one game 1.5 years ago (such programs are often called “Autopatchers”), I didn’t think that there could not be so many people who would scream not that the program has a bad design or bugs, but that you need to download 20 megabytes of the .Net Framework 2.0.
')
Life has taught me to study the market first now, because even the most beautiful and correct application may not be appreciated if the user needs to perform gestures that may cause him to slip from a hand from pressing a heap of unnecessary buttons in program dialogs to what he needs to spend penny 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 great reviews about WPF technology from my friend, he had one problem: he couldn’t open 80% of the possibilities, because a normal book appeared in the summer (of those where technology is described in detail and fairly accessible), and before that it was possible to gather information only from blogs, in which, often, a lot of things were overlooked ...

Having heard it, and having managed the experience, I first began to read a book that had been refreshed by this time, along with the framework to version 3.5. Much has escaped, and still continues to elude my understanding, but now there is where to dig: Western bloggers-programmers, having bitten the fruit of WPF, stuck like a machine gun, and ours are starting to catch up.

What is WPF?



In Windows, from version 3.11, there was a GDI display component, and it was later updated; in Windows XP, if I'm not mistaken, GDI + is already in use.
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. She had other problems, but she didn’t have a strong problem with processor utilization for redrawing models.

Apparently the solution from Microsoft matured long ago, since they integrated WPF into Vista and Server 2008, which, I think, gave a greater impetus to its use than all sorts of seminars and articles. This, by the way, gives an additional plus, since the model of redistribution of applications using 3 and 3.5 frameworks is simplified.

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

In WPF, at the moment there are 3 levels, to determine how the mold and the 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 involved. Approximately DirectX 9 and above.


How to find out what 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) New descriptive model of the form and interface in principle - XAML
b) New build model: meaning not compiler at compiler level,
and a new model for incorporating one into the other. Example (insert checkbox into textbox).
c) New related controls and methods for print and media.
d) New data binding model.
e) New features in forms.
f) Much more that I have not yet learned.
g) The ability to transfer the project to the Web almost painlessly
(I will tell you about the XBAP Rich Web Application in a couple of articles).
h) Animation.

Yes, it’s probably wrong to call everything everywhere forms, because the model consists of windows and pages, the pages can be loaded accordingly, in the web version, in the normal version, through the Frame component or through the Canvas, for example, in WPF / E (SilverLight).


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


In the next article I will look at XAML. In short, while I say that XAML
(eXtensible Application Markup Language) is a special descriptive language for
documents, windows and pages, something like, sort of a mixture of XML and HTML.

Well, a simple example of a window (XAML only):

  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. <Grid>
  7. <Grid.ColumnDefinitions>
  8. <ColumnDefinition> </ ColumnDefinition>
  9. </Grid.ColumnDefinitions>
  10. <Grid.RowDefinitions>
  11. <RowDefinition> </ RowDefinition>
  12. </Grid.RowDefinitions>
  13. <TextBlock Grid.Row = "0" Grid.Column = "0"> Hello World </ TextBlock>
  14. </ Grid>
  15. </ 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 markup and small pieces.

In conclusion, I would recommend the book on WPF:

1) WPF. Windows Presentation Foundation in .NET 3.5 with examples in C # 2008 for professionals
Author: Matthew MacDonald.

Impressions:

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


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

Impressions:

“In general, the book is written very well, but it seems that, after all, there is too much detail in detail and there are inaccuracies in the translation” - this is from the words of the person (who was mentioned in the narration 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
www.beacosta.com/blog - all about WPF Data Binding
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/

English books

Pro WPF: 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 Vladek habourer for help in completing the post and habauzer XaocCPS for reviewing it)



I would be glad if you complete this list, especially with books in English,
because I haven’t studied them yet, but I’ve seen them or make clarifications to the article. Thank!

Source: https://habr.com/ru/post/40850/


All Articles