DataGrid export excelb: server-side export. obtain the DataGrid data source. passed to the WCF Service to the server. then, the transmitted data is processed and exported using the Excel method in Asp.net. 2. It cannot be called, because the DLL called by Silverlight can only be a DLL compiled using the Silverlight class library, that is, the DLL to be compiled in the Silverlight runtime), the C ++ class library and. net class libraries cannot directly call 3 SL when asynchronously calling the web service, you must note that the first error occurs. In this case, each cycle sends an asynchronous request to load the getdatacompleted event once, five times in total, when the getdatacompleted event is loaded for five times, the ansyc (I) request is sent 5*5 = 25 times. This is incorrect! If the second method is correct, an asynchronous ansyc (I) request can be sent every time, but the getdatacompleted event can be loaded once after the loop is completed, 4 silverlight2 currently supports JPG and PNG formats, and some PNG codes are not supported. At the same time, some PNG files are invisible in the design preview of XAML, but are visible at runtime. For more information, see <stackpanel background = "white" orientation = "vertical"> <image X: name = "blue" Source = "/images/blue.png" stretch = "NONE"/> <image X: name = "green" Source = "images/green.png" stretch = "NONE"/> </stackpanel> backslash forward-slash? Is there a difference between Xiami ?, Named resource test example solution Resource Manager and running effect: Blue images starting with a backslash must be placed in the corresponding folder in the clientbin directory; green images that do not begin with a backslash should be placed in the corresponding folder under the Resource Directory. Otherwise, an imageerror occurs. Why? The two are both relative paths. What is the difference between the backslash? The relative path at the beginning of the backslash, which indicates the root directory of the application running. in the xap compressed package, if the file to be referenced is not found in this file, the fallback mechanism of the relative path is automatically in. the directory where xap is located. In this example, It is referenced in the clientbin directory. If there are no two locations, an error will occur. If it does not start with "/", the relative position is the directory where the XAML file that references the image is located. In this example, the Resource Directory where the page. XAML file is located. So which method is used? Rename the xap file as a zip file, decompress it, and decompile the DLL file with reflector. It is found that it contains the green image, but there is no blue image. In fact, it is obvious that the images folder where blue is located is similar to. xap, which is naturally not included. We can see that green images starting with a backslash are not embedded in the xap file in the Silverlight program and downloaded directly to the client, while Blue images are requested as needed (on-demand ), download the SDK when it is displayed. When the data volume is large, it takes too long to load the program without starting with a backslash, and the user experience is poor. This scheme is naturally unavailable if it starts, however, if it starts with a backslash, it is not visible in the design preview of XAML. It can be seen only when the program is running. (For preview, copy a copy from clienbin and put it in the same directory of page. XAML for design and use. Delete the copy when the program is released .) In addition to directly determining the source URI of the image in XAML, you can also determine it in code-behind. At this time, the backslash usage is consistent with that in XAML. C #: Image IMG = new image (); IMG. source = new bitmapimage (New uri ("test.jpg", urikind. relative); // page. under the directory where XAML is located // IMG. source = new bitmapimage (New uri ("/test.jpg", urikind. relative ));//. in the directory where xap is located, it is okay to use urifiles such as http://www.liongg.net/test.jpg. In the code, you can also use methods such as application. Current. Host. Source. absolutepath. I tried it and found that it was too troublesome and I didn't want to worry about multiple methods. A little deeper, even if the image is placed in a folder at the same level as page. XAML, you can use a backslash to reference it. You only need to select build action as "content" in the corresponding image attribute, but the image is still put. the xap package is in. For more information, see sivlerlight resource overview. 5. Three types of bindings are supported in Silverlight: oneway, twoway, and onetime. the default value is oneway. one-way indicates that only the data source is bound to the target (usually the UI object). One-way means that the data source can be bound to the target, and the changes to the target can also be fed back to the data source, update it. Onetime is a special case of oneway. It only loads data once. Subsequent data changes do not notify the bound target object. In this way, it can bring better performance. The binding syntax can be represented by braces. The following are several examples: <textblock text = "{binding age}"/> is equivalent: <textblock text = "{binding Path = age}"/> or explicitly write the binding direction: <textblock text = "{binding Path = age, mode = oneway} "/> according to the Data Binding semantics, the default value is oneway. That is to say, if the background data changes, the control related to the binding relationship established on the foreground should also be updated. For example, we can change the data source mentioned in article (1) to a private member on the current page, and then change the value in a button click event. The Code is as follows: public partial class page: usercontrol {private list <person> persons; Public page () {initializecomponent (); Persons = new list <person> (); for (VAR I = 0; I <5; I ++) {persons. add (new person {name = "person" + I. tostring (), age = 20 + I});} list1.datacontext = Persons;} private void button_click (Object sender, routedeventargs e) {persons [0]. name = "Tom" ;}} but we click the button to find that the data in the ListBox has not changed. This is because no notification is sent when the data source is updated. We can enable the inotifypropertychanged interface for objects in the data source to send related notifications when the bound source attribute value changes. The Code is as follows: public class person: inotifypropertychanged {private int age; Public int age {get {return age;} set {age = value; policypropertychange ("Age ");}} private string name; Public string name {get {return name;} set {name = value; policypropertychange ("name") ;}} public event propertychangedeventhandler propertychanged; private void policypropertychange (string propertyname) {If (propertychanged! = NULL) {propertychanged (this, new propertychangedeventargs (propertyname) ;}} 7 1. for IIS6 or earlier versions, you need to add the MIME type as follows: xap application/X-Silverlight-app XAML application/XAML + XML xbap application/x-ms-xbap8 aspx and xap parameter transfer method 1 idictionary <string, string> paras = htmlpage. document. querystring; this. lblusername. TEXT = paras ["username"]; this. lblemail. TEXT = paras ["email"]; method 2. ASPX page this. xaml1.initparameters = string. format ("username = {0}, email = {1}", request. querystring ["username"], request. querystring ["email"]); xap page = new page (); page. username = E. initparams ["username"]; page. email = E. initparams ["email"]; this. rootvisual = page;
Please understand the operating principles of. Net GC. If you find memory leaks, you can use windbg for debugging. First, check whether it is. net managed heap occupies a large amount of memory. In this case, use the gcroot command to debug and check which objects occupy the most memory. The GC root command is used to trace the source, finally, you can determine whether it is a code issue or a runtime issue (very unlikely ).
As far as I know, there is no good way to force GC in Silverlight. The "Timing" refers to how Silverlight determines the amount of memory available to the system and many other factors for selection. 3. In Silverlight, when you jump to other pages, set all controls and user controls in the variables to null, and delete all registered external events 4. In idispose, remove the external events, in this way, register external events 5. If you want to remove the user control, you can set the children in the container to null to prevent memory leakage. Make sure there is no reference to usercontrol1 stored elsewhere, usercontrol1 removes external event registration. 6 WCF and WCF Ria Service Location: http://blog.csdn.net/fangxinggood/archive/2011/03/17/6255140.aspx7 if you put the picture in the xap package, when you change the picture, the client will re-download the entire xap package the next visit. Because you have changed the image or modified some code in the program and then compiled it, it will get a new xap package, and when the browser accesses it, it detects updates to the xap and then downloads the xap package again. Generally, we do not recommend placing images in the xap package (that is, you add images to the Silverlight project), but on the server, then access the image with the correct path in Silverlight, so that the xap size will not be too large and the access speed of the client will be affected (you think, if you have a lot of images, if all the images are stored in the xap package, the client must download all the images, that is, the entire xap package, and then run the Silverlight program. The access speed can be imagined ), the xap package will not be downloaded again after the image is modified. 8 http://social.msdn.microsoft.com/Forums/zh-CN/wcfzhchs/thread/16a159f1-f8f6-49f8-9b6a-9ad6ffe7b7a89 blue pictures starting with a backslash need to be placed in the corresponding folder under the clientbin directory; green pictures not starting with a backslash should be placed in the corresponding folder under the Resource Directory. Otherwise, an imageerror occurs.