Warning Reader: Because it is an event-driven mode of high-speed learning, high-speed learning means, not systematic, unscientific, illogical, not necessarily correct. So if there is a wrong place, leave a message to me under the page, kneeling thanks!
Background Introduction:
Recently, in the company's development work, took over from other companies to account for the code troll, the main technology has WPF, Control reversal Frame Spring.net,sqlmap (sort of like ibatis.net), Remoting, Job Scheduler Framework Quarz, our job is to put this monster, smash, reorganize and optimize, the target is to re-compose Webapi bottom and WPF interface two parts, below is my study of WPF The process, left some very (Luan) have (QI) See (BA) (ZAO) notes.
notes:
At the beginning of the study, I usually ask myself not to devote too much attention to the history of a technology, the English full name (Windows Presentation Foundation) These questions, this to the actual production, and no practical effect, I strongly ask myself only to focus on how to start, and begin to get used to the "Question answer framework" (what is it?) Why? What do you think? ) to perform learning assignments.
WPF's "What" and "why", I think there are a few things to figure out:
- There are already winfrom, why should there be WPF? What's the improvement?
- What kind of knowledge will be used in the face of the ground?
- What about the technology of the same period?
1. Answer:
I started the Web (ASP), Winfrom are not very familiar with the sudden development of PC interface, it is a bit unprepared, but WPF XAML interface language is really bright, since it is the ML language, then xml,html syntax and XAML should be the same, As a result, the only thing left is the familiarity of the label, which is a great boon for Web developers.
WPF is, in a sense, much like winfrom, you can develop WPF very winfrom, after you create a WPF solution, drag a control (button) directly onto the interface, and then double-click Add Event.
But it can also be a Web page to develop some from, for example, want to do a login window, you will inevitably think of such a child HTML code:
name:<inputtype= "text"ID= "txtUserName">Password:<inputtype= "Password"ID= "Txpassword"><inputtype= "Submit"ID= "Btnsubmit"value= "Submit">
So it seems that WPF also provides a similar structure:
<x:name= "Btnpageevent" Content= "point me!" " Margin=" 441,0,0,0 " Click=" Btnpageevent_click "/>
At this point winfrom gives me the feeling of being particularly troublesome, you usually can only drag and drop the way to add controls, if you want to write code to add, Disigner.cs's code readability is really disgusting, which means that the development of the interface and the development of the code are separated, and the reusability of the interface code is enhanced by many.
2. Answer:
The most immediate, of course, is the XAML mentioned above, then there is the MVVM framework, and then we want to talk about performance and content separation like HTML+CSS, and then talk about Silverlight (though I haven't learned yet, I feel that the animation of WPF is exciting)
3. Answer:
WPF has a few schoolmates, WCF,WF, the new phase of the MVC framework and so on, are very competitive, attractive knowledge and tools. Why do you know this? Because I would definitely put WPF and WCF
So how do we get started?
First of all, this is not to start from scratch, this is someone else's company has been engaged in several years of code, others Home Company's Knowledge (yuan) (Shi) (ju) Right (Keng), to you code already very worthy of you, how can there be documentation?
Practice out of the truth, of course, to begin to write, will understand, I simply sorted out the code of the monsters inside some of the frequently appearing controls and words, through the book "WPF compilation Bible: Using C # 2012 and. NET 4.5 (4th edition)", I simply put them into the following categories:
- Basic WPF Controls (Button,radio,checkbox,datagrid, etc.)//(Everyone needs to have it!) )
- WPF layout Controls (Grid,stackpanel,border, etc.)//(the word layout is something to be touched on PC software)
- Binding of elements (binding,observablecollection)//(ViewModel binding operation for MVVM)
- External resources of elements, styles or converters (StaticResource)//(Representation and content separation)
- Trigger for event (Triggers,eventtrigger,icommand)
Well, so the question comes, and I find it often written like this:
1 style= "{StaticResource SimpleButton}" 2 commandparameter= "{Binding elementname=gdtasklist, path=selecteditem}" 3 binding= "{Binding createtime, Mode=twoway, updatesourcetrigger=propertychanged, converter={ StaticResource Datetimeconverter}} "
At this time I can not help but constantly spit groove, this is what ghost ah ...
- + = The binding also contains a JSON-formatted object with a binding inside it?
- =-StaticResource, where is this resource? Where did you bring it in?
- = = Mode, UpdateSourceTrigger, Converter, where are the attributes of their own?
- = Converter you naughty again, how to take a StaticResource, this is not the element of the style of resources? How did you get to the converter?
No, it can't go on, it's messy. People are a big team, people are definitely not fools, after all, a few years of code, then chaos, there is its composition. We have to put aside all this work for the time being, learning a little basic knowledge is right:
MVVM:
This thing may be a bit difficult for the traditional handlers, everyone is very accustomed to the MVC set, the user to Controler request, and then the controller put the view and model together to bring to the user, but also very popular with three layer development.
(My Learning order may be a bit of a non-mainstream, I was first learned the web above the knockout.js, to MVVM have a preliminary understanding, then learn the WPF.) )
That's how I understand MVC and MVVM:
We make the page, we take out the data, respectively, is two objects, for MVC, we see the page and data, is the controller from the data to find a corresponding attribute, and posted to the view corresponding to the place, attention is one to find, and for MVVM, The pages and data that we see are pre-tagged with the pages you want to fill out here, and the data is snapped and stacked on the page.
May say is not clear, I give an example, do not know that the reader has not seen very old-fashioned projector (film projector, see), but now basically equipped with a high-level projector and physical projection, when I was a child in class, the teacher will put the exercise in a transparent paper, and then take another sheet of paper stacked on the top of the exercise , write the answer. In class, the teacher first wrote a projection of the exercise, we do exercises, and then write the answer to a stack of exercises on the top, so that you can answer. Well, what I'm talking about here is the "stack" operation, which gives me a feeling like the bind operation of MVVM.
Build the project:
Only 3.5 of the. NET Framework has WPF, so it's better to have more than 2010 Code development tools (Everyone download the 2015 Community version, for free).
New project, New project ...
Well, it's hard to fail me ...
End:
Well, we haven't written a single line of code, and it's over,
It's been a little more than a few months of harvesting,
Yes, the rice will stutter, the notes will be a little bit tidy,
But I think it's a good start.
At least for me, yes ...
WPF Learning Notes (1)--(accumulated from May 1, 2016 to June 1, 2016)