C # For Xaml #
As mentioned above, a more fun and unique Silverlight development mode is introduced-now and instantly changed. As mentioned above, this mode itself is quite cool. The XAML you just changed and the UI you changed can be directly displayed on the interface without going through the compilation phase. But the problem is that in our actual business process, there must be corresponding C # code to correspond to this XAML. This article explains how to implement it.
Let's talk about the traditional Silverlight development.
In traditional development, even if we make any minor changes to the Silverlight program, we have to go through the following stages.
1: regenerate the DLL file.
2: SetAllTo form an XAP.
In short, if the XAP package is composed of 20 DLL files (this is a normal one. Generally, if you reference some third-party DLL files, you can collect 20 ). I first compiled and generated an XAP package. Later, the program was modified, and a DLL file was slightly changed, but a new XAP package was generated. Note that the two XAP packages except the modified DLL are identical. This is so uncomfortable. For a modified DLL, other DLL files must be compressed again ....
In my opinion, it is better to put the DLL of this self-Written service on the server. When my business DLL has been modified and compiled, it does not need to be repackaged into XAP, so it will be much faster to compile and not package. As mentioned above, this DLL does not contain a XAML file, so it is not very large. I have worked on a project, 15 pages, and the DLL file after code compilation is less than 50KB. Very small ......
Code on
Http://files.cnblogs.com/MySilverlight/demo3.zip
Code Description
First, find... \ SilverlightApplication2 \ SilverlightApplication2.web \ ClientBin \ MyXaml \ XamlShow. sln as mentioned above and remember to use Blend to open it.
Then use VS to open SilverlightApplication2.sln. Press F5 and click the button. The following page is displayed.
Click ......
You must pay attention to the following points.
1: The Click Event of button A is placed in
2: Please note that this Silverlight class library project is placed in
This is stored on the server. After your Test is modified and compiled, refresh the interface to see the changed part.
As for code implementation, it is estimated that it is a big drop. It is estimated that there are only 10 lines of code before and after.
It's just a reflection.
Remarks
Of course, this is just a rough explanation of the idea: Put the Business Code in a separate class library without mixing the XAP package. Of course, the above Code does not completely solve the problem of 'code Post. For example, if I want to define a Converter, where should I put it ?? How can I reference it in XAML ?........ Or in the next sentence
As mentioned in the previous article, the articles written during this period are actually a series. In the first two articles, I added this article to my main framework.
Any business system is composed of many pages (please note that I am talking about enterprise-level development and I am not familiar with Internet Development )..... The development process is actually the process of developing pages one by one.
In my development mode, loading a page involves three steps.
1: Download The XAML file from the server and form the interface (http://www.cnblogs.com/MySilverlight/archive/2012/05/26/2518798.html)
2: bind data (http://www.cnblogs.com/MySilverlight/archive/2012/05/24/2516970.html ).
3: 'Code Post' (this article ).
I have written three methods for these three steps. InnitUI, InnitData, InnitCodeBehind.
Go to bed.
Next, let's talk about my first Async experience. During my development of Silverlight, a large number of asynchronous programming made me suffer. It is not until the key to responding to the call of the master laozhao to use Async Await that it is relieved. The use of Async also makes my framework more stable and easy to use.