Silverlight file manager




















The GetLocalFolders method returns a collection of folders in the Files directory. The GetLocalFiles method requires a folder name to be passed as a parameter, and it returns a collection of file names, as well as a link to download the file by passing the folder and file name to the DownloadFile.

We will now open the solution in Expression Blend 4 or higher and create the Model and the ViewModel. However, first, we will add a simple class to support Commanding. Commanding will allow the Designer to raise an event in the ViewModel. In the Models folder, add a class called SilverlightFolders. This is a class that calls the GetFolders and GetFiles web service methods. A few things to note:. This is the class that will be consumed by the designer.

The designer will not actually need to see this code, it will show up in Blend, in the Data section, when the designer sets this class as the DataContext for the UI page. Note that this class implements ObservableCollection , so that changes to values stored in the class will cause a notification to any UI element that is bound to it, so it can automatically update.

The class also implements INotifyPropertyChanged so that properties will also provide automatic change notification to any UI elements that are bound to them. A UI element such as a Button , or in this example, a selected node on a TreeView , can bind to this property and call the SetFiles method that was registered using the DelegateCommand in the class constructor. We have finally arrived at the real point of this article.

Allow me a moment to drive home the point that the View Model Style pattern in Silverlight allows us to create an application, yet not specify a UI at all. The UI can be created entirely in Blend without writing a single line of code. Why is that important? Because the programmers need no longer hold the designers back.

The programmers don't intend to hold anyone back after all, I am a programmer , but normally nothing can go to production without the programmers implementing it. Designers can now take charge of a project that has implemented the View Model Style pattern, and create new innovative user interfaces that do not have to go through a programmer. We can expect a lot of advances in user interfaces in the coming years, now that we have taken the "shackles" off of the designers.

Now, imagine that a programmer has created the previous files. If the upload is complete, the SetFiles SelectedSilverlightFolder call refreshes the current list of files, and causes the uploaded file s to display in the file list. All I did was strip it down considerably. There is still a lot of code that could be still stripped out, because the class no longer has to manage the UI of the original project.

However, I stripped it down enough that others should have a fairly easy time adapting this for their own uses. Basically it uploads the file chunk by chunk. The careful management of this process is the beauty of this class.

If it has any problems it was surely introduced by me. There are others ways to handle uploading files, but I have used this code for years, on a number of different projects, and this code works great for me. The web server code is more strait-forward.

Basically it communicates with the FileUpload class. Again, I simplified it so it would be easier to customize. The code for the. By passing UI elements to the ViewModel using ICommands and wiring-up events to these elements as needed, you can achieve full Microsoft Expression Blendability and testing. Pass it a UIElement , raise the event in your test method, and compare the expected result.

When you pass UI elements as parameters, you can hook up any event such as MouseDown. This allows you to respond to a direct action, rather than attempting to infer an intent in the View purely through bindings. While this may seem like you are tying your ViewModel to your View , the actual UI element being passed can easily be changed by the Designer. Trending from CNET. Microsoft Silverlight bit By Microsoft Free. Download Now. Premium Upgrade. Developer's Description By Microsoft.

Microsoft Silverlight bit is a cross-platform, cross-browser, and cross-device plug-in for delivering the next generation of media experiences and rich interactive applications for the Web. Now with new mobile device focused implementations of Silverlight, developers and designers can easily take existing code, assets, skills, and tools and deliver superior user experiences on mobile devices. With initial support for Windows Mobile and Nokia S60 including any S60 based handset mobile operating systems Silverlight provides broad reach into the mobile space.

Full Specifications. What's new in version 5. Version 5. Release December 14, Date Added December 14, Operating Systems. When the FileUpload status changes for example when it is complete the following method is raised. If the upload is complete, the SetFiles SelectedSilverlightFolder call refreshes the current list of files, and causes the uploaded file s to display in the file list. All I did was strip it down considerably.

There is still a lot of code that could be still stripped out, because the class no longer has to manage the UI of the original project. However, I stripped it down enough that others should have a fairly easy time adapting this for their own uses.

Basically it uploads the file chunk by chunk. The careful management of this process is the beauty of this class. If it has any problems it was surely introduced by me. There are others ways to handle uploading files, but I have used this code for years, on a number of different projects, and this code works great for me.

The web server code is more strait-forward. Basically it communicates with the FileUpload class. Again, I simplified it so it would be easier to customize. The code for the. By passing UI elements to the ViewModel using ICommands and wiring-up events to these elements as needed, you can achieve full Microsoft Expression Blendability and testing. Pass it a UIElement , raise the event in your test method, and compare the expected result.

When you pass UI elements as parameters, you can hook up any event such as MouseDown. This allows you to respond to a direct action, rather than attempting to infer an intent in the View purely through bindings.

While this may seem like you are tying your ViewModel to your View , the actual UI element being passed can easily be changed by the Designer. You are commenting using your WordPress. You are commenting using your Google account. You are commenting using your Twitter account.



0コメント

  • 1000 / 1000