Silverlight
There are 40 entries for the tag
Silverlight
Over on our forums, many of you have reported difficulty with the ComboBox control when using RIA Services. Kyle McClellan (@KyleMcClellan) suggested that we drill into various ComboBox scenarios to see what works well and what doesn’t. Our goal was to produce some samples that address common scenarios, and to offer general guidance for ComboBox usage. Here are a few scenarios we looked at: Async loading of ItemsSource with a SelectedItem/SelectedValue binding; Cascading drop-downs such as selecting Year - Make - Model for a car; Binding...
Almost a year ago, I posted a lengthy article on how to implement Async Validation with RIA Services and DataForm. It was hard; much harder than it should have been, and we all knew it. Since then, things have changed, and async validation is a lot simpler. Let’s take a look at why it’s easier and how you can easily perform async validation in your application. INotifyDataErrorInfo Silverlight 4 shipped with an interface called INotifyDataErrorInfo, and controls that previously supported validation by way of exceptions now support async validation through this interface. This laid the groundwork for RIA...
As the RIA Services team is wrapping up our V1 release, several team members have been diving into the forums, writing blog posts, and in general trying to connect with the community to make sure we’re tying up all of our loose ends. We would also like to make sure that we have our documentation bases covered, but we’d like to solicit some candid feedback for this area in particular. Documentation Approaches What forms of documentation would you like to see us work on? Do you like quick-start tutorials, or do you prefer deep-dives? How would you prioritize...
Of all changes that made it into the RIA Services RC release, one of the ones that I'm happiest about is the deletion of a class called ControlParameter. Yes, ControlParameter is gone, gone, gone--finally! If you’re wondering how you’ll get your UI-based filters and parameters to work without ControlParameter, do not fret… it’s easy; just use an ElementName binding! Let’s take a look at the changes related to Filters and Parameters… ControlParameter is gone… Good Riddance! Since the inception of RIA Services, the DomainDataSource control has relied upon ControlParameter tags for specifying Filters and Query Parameters that...
With the release of the RIA Services Release Candidate, it was time to refresh the ContosoSales application that was first shown in the PDC keynote. Let’s take a look at the changes made to move to the new release. The steps below are based on having downloaded the styled ContosoSales application from PDC. If you want to cut to the chase and download the new version of the solution, you can grab it here for use with the RIA Services RC bits. Changes to References In trying to migrate the application, the first thing we notice is...
The System.ComponentModel.DataAnnotations.ValidationResult class was created for RIA Services, and it was introduced in Silverlight 3.0 and then added into .NET 4.0. A ValidationResult represents a validation error condition, specifying the error message and, optionally, any member names that the error corresponds to. If you use the [Required] attribute, the [Range] attribute, [StringLength], or any of the other provided ValidationAttribute classes, then ValidationResult instances are created to represent any validation failures. If you have used the [CustomValidation] attribute or if you have derived from ValidationAttribute yourself, you have likely returned an instance of ValidationResult in your code, or ValidationResult.Success if validation...
With the RIA Services July 2009 Preview release, we heard significant feedback about the DomainDataSource error handling story. The biggest problem was when errors occurred during Load() or SubmitChanges(), server-side errors would be silently swallowed unless you opted into the LoadError, LoadedData, and SubmittedChanges events, and explicitly checked for errors. With the PDC release, we've change this behavior, among others related to error handling. Different Error Conditions The DomainDataSource can encounter errors in several different ways: Load() is called when its prerequisites are not yet met. For instance, there is no DomainContext specified, the...
During Scott Guthrie’s keynote at PDC09 (starting around 1:28:00), Scott Hanselman presented a demo that highlighted Visual Studio 2010, Silverlight 4, RIA Services, and lots of great new tooling that ties all of these products together. I wanted to show you how you can build the same application using installations that are available today. Machine Setup You’ll need to install Visual Studio 2010 Beta 2 if you haven't already. If you have a previous release of RIA Services already installed, you’ll need to uninstall it before proceeding. Please note that you want to keep the Silverlight 3 SDK installed...
DomainDataSource has two properties for getting the data out of it: Data and DataView. The Data property is what’s intended for exposure in Binding scenarios, for instance binding a DataGrid to the DomainDataSource. This property is typed very simply as an IEnumerable. The DataView property however is intended to be used for programmatic access to the entities exposed by the DomainDataSource. While the two properties currently return the same collection instance, this might not always be true, so it’s good to properly set the expectations of these two properties. If you need to work with the collection from the DomainDataSource,...
During the PDC release milestone of RIA Services, we discovered an error from DomainDataSource when using AutoLoad="True" and when using a DataPager bound to the DomainDataSource’s Data property. We found that when the PageSize property is specified on the DataPager and not on the the DomainDataSource itself, an exception would often (but not always) be thrown from DomainDataSource, indicating that a load could not be invoked while another load was in progress. The reason for this will actually interest you most if you use AutoLoad set to False. The issue is easiest to explain with a series of events...
While the DomainDataSource is most often used for loading entire sets of records, it can also be used for loading a single record result. This is a topic I’ve seen a few people talk about, assuming it’s a difficult thing to do, and even creating solutions for a problem that doesn’t exist. I want to dispel the myth here: DomainDataSource can in fact be used to easily bind to a single record result. Let’s create a DomainService that has a method to get the most recent error from the AdventureWorks database: ...
ASP.NET Dynamic Data introduced the System.ComponentModel.DataAnnotations namespace in .NET 3.5 SP1. The namespace contained a bunch of attributes for applying validation rules to objects and their properties. With the “Alexandria” project (which morphed into .NET RIA Services plus some Silverlight/SDK/Toolkit additions), we were exposing your server-side entities up to your Silverlight client. In doing this, we wanted to preserve your DataAnnotations attributes on the client, which of course meant that we needed a Silverlight version of this assembly. (See Also: Sharing Source with Silverlight). As our team was creating this Silverlight assembly, we found that we needed...
Tom Beeby posted a topic on the RIA Services forums about adding a new entity via the DataForm buttons. Specifically, he pointed out a problem where the DataForm does not light up the Add/Remove buttons when bound to an EntityList from your DomainContext. To exacerbate the problem, it turns out that binding to an EntityCollection<T> from RIA Services won’t let you Add or Remove either. I’ve dug into this problem with some team members, and we’ve identified the cause of the problem. To be clear, binding a DataForm and getting Add/Remove support works just fine when you’re binding to...
I am one of the proud folks that gets to work on the System.ComponentModel.DataAnnotations assembly. This assembly is used by several products, and it seems more are starting to depend on it. Part of the fun with this assembly is that it exists for both Silverlight (as of Silverlight 3), and the full .NET Framework (as of .NET 3.5 SP1). I am responsible for managing source code sharing of this assembly for the two frameworks; in fact, I’m doing some work today related to this. Phil asked me for tips on how to work on projects that need to...
Awhile back, I blogged about how Silverlight uses Validation Exceptions, which can cause the debugger to break. I showed how to prevent that from happening, but the solution was less than ideal. Someone named rlodina commented on the post: What about manual adding: System.ComponentModel.DataAnnotation.ValidationException in this list. This comment has been sitting in my inbox for about a week, and I had wanted to follow up on this. Well good gosh, this is easy and it works like a charm. You can in...
There have been a couple of discussions on the .NET RIA Services Forums regarding the DomainDataSource.DataView property. Colin Blair tossed in a comment that relates to something we’re working on: This looks like as good a place as any to say I would like to see the actual object behind IEditableCollectionView exposed publically. … Right now, the DomainDataSource’s Data and DataView properties are returned as interfaces: Data is an IEnumerable, and DataView is an ICollectionView. But behind the scenes, both of these properties return an instance of an EntityCollectionView,...
With the .NET RIA Services July 2009 Preview, the DomainDataSource now enables some scenarios that were previously blocked. Most namely, we now allow you to change your current page while there are pending changes in the data. Editing and paging seemed like a common enough scenario that we wanted to enable it, so we’ve done so in the recent drop.
There are actually many scenarios opened up right now that we’re reviewing. I’ll be frank: many of the following scenarios are probably doing really wonky things in the current bits. So here’s your chance to help us determine how these scenarios...
Please note… this post is out-dated and all of the madness below is no longer needed in order to implement Async Validation with RIA Services. Please see the new post for the current approach. The Birth of QuickSilverlight.Validation Over on the .NET RIA Services forums, “SilverlightRIA” asked about performing asynchronous validation with .NET RIA Services and the Silverlight Toolkit’s DataForm. He wanted to intercept the Commit from the DataForm and invoke his async validation, integrating the results into the DataForm’s validation UI. This was an interesting scenario so I put some time into a solution for it this...
System.ComponentModel.DataAnnotations offers a RangeAttribute that can be used to validate that a value is within a given range. Silverlight 3’s SDK includes this assembly and .NET RIA Services and ASP.NET Dynamic Data use this too. Something that a few of us have stumbled on here internally is that the RangeAttribute doesn’t have a constructor that takes Decimal values. In fact, a bug was submitted by another feature crew for this. Unfortunately, even if RangeAttribute offered a constructor that accepted decimals, you still wouldn’t be able to pass them in. Here’s what the code would look like: ...
With the Silverlight 3 Beta SDK and .NET RIA Services, a lot of people are starting to utilize the System.ComponentModel.DataAnnotations library to add validation metadata to their entities. Something that has tripped up some people is the use of exceptions for validation errors, where Visual Studio breaks with a user unhandled exception. As Keith Jones reported, Silverlight 3 uses exceptions to notify controls when validation has failed. This means that many users will see Visual Studio break when these exceptions occur and be led to believe something has gone wrong. But everything’s doing what it should. If you hit...
.NET RIA Services allows you to write code on the server in an ASP.NET project, and have it available within a Silverlight application hosted by that web project. Using build-time code generation, your entity types in the server project become available within the client project. You can get .NET RIA Services today and provide feedback on the forums. Well, I am working on a scenario where I needed to have an entity implement a custom interface on both the server and the client. I immediately wondered, “How on Earth will the code generation know to propagate my interface implementation...
Shipping software is hard. It can sometimes be just as intense (or more so) than writing the software. For many months, my team at Microsoft has been working on some great new features in Silverlight 3 and the Silverlight 3 SDK. I had the pleasure of working to prepare our contributions for the SDK release. I’ve shipped a lot of software. In fact, I’ve been involved or responsible for the shipping processes at Business Integration Group (BIG), WeDoWebStuff.com (the company I co-founded in 2000), MultiLateral Solutions, and Structural Dynamics Research Corporation (all the way back in 1998). But what...
Ever since I started at Microsoft, I’ve been part of a team working to deliver a lot of things that are hitting the streets today. It’s been a wild ride and it’s great to see our work going public. Here is some of what is most exciting for me to see in public: .NET RIA Services Validation Navigation ChildWindow There’s going to be a lot to take in over the next couple of days with the MIX sessions, but I look forward to...
Not long after I joined Microsoft, I was looking at the Silverlight Airlines code sample. I was new to Silverlight, so I used this demo as a way to help learn Silverlight. The demo app is pretty cool, and ScottGu showed it off at Mix, so I had seen it before. I took on an exercise to attempt to add some features to the application, and this helped me learn more about Silverlight. To select a flight, you drag your mouse from one city to another, and then drag over the date range for your travel. ...
This is something that has bitten me several times, so I thought I’d write it down. Maybe I’ll remember, and maybe I’ll help others when they hit this too. The scenario happens when you want to create a new control that can have a template applied to it. Let’s start with this control definition: 1: using System;
2: using System.Windows.Controls;
3: using System.Windows.Markup;
4:
...
One of the reasons why the ViewModel pattern is so powerful in Silverlight and WPF is because Binding Converters can do so much. As we saw in HelloWorld.ViewModel, a ViewModel can expose a boolean property that is consumed as a Visibility value for controls. This requires some glue to convert the boolean to the necessary enum, and that’s where our VisibilityConverter comes in. If you want to see this in action, go check out the sample code, but here’s how the VisibilityConverter works. In order to create any binding converter, you can start off by creating a class that...
A few folks asked me to provide a ViewModel sample of some sort. I thought this was a great idea, since I don’t know that I had seen a straight-forward ViewModel sample yet. So here it is: HelloWorld.ViewModel! Click the image to view the Silverlight sample live. Let’s start out by looking at the code for the ViewModel class, since that’s the file that I authored first. 1: using System;
2: using System.ComponentModel;
...
When I was at BIG, I created what I called the Extended MVP pattern. I built a framework that was used on multiple projects for managing the presentation layer as well as validation. I’m still very happy with what I created, and my teams at BIG are still pleased with those applications as well. In fact, I just learned that they were looking into using the pattern within a Silverlight project they’re doing a proof of concept for. I mentioned the ViewModel pattern to them, suggesting they use it instead of using the MVP approach. When asked for more information,...
Tonight, Silverlight 2 is being released to the web (RTW). This release marks an important milestone for .NET developers, probably more so than most realize. Silverlight 2 provides a browser control that can host .NET assemblies. If you’ve been living under a rock, or if you just haven’t been following the Silverlight story, this is news to you; but chances are, you’ve heard this before. But if this doesn’t make you jump up and down with excitement, then you might need to sit back and really think about what Silverlight 2 can do for you. And then jump and...
After I posted about how to regain tab navigation in a popup, Ian commented that the workaround had some flaws. First, he lost intellisense inside the <UserControl> and second, which is more painful, he could not refer to any controls inside the child <UserControl> from the page's code-behind. Well, I found a more suitable workaround. Instead of using a <UserControl> to set the TabNagation, you can use a <ContentControl> instead. Here's the updated workaround code: 1: <UserControl x:Class="PopupTabbing.Page"
2: ...
One of the approaches I've tried using to combat the PropertyChangedEventHandler nuisance is an extension method on INotifyPropertyChanged. Actually, a pair of them. One accepts a single property name and the other accepts a param array of property names, so that events can be fired for multiple events succinctly. 1: /// <summary>
2: /// Raise the specified PropertyChangedEventHandler for the sender
3: /// and property name, but only when the handler is not null
...
While building an app in Silverlight 2 RC0, I was trying to use a Popup to display a login form. Pretty basic form: Username, Password, button. But I immediately noticed that I could not hit Tab to move from one field to the next. Here's some XAML that demonstrates the problem: 1: <UserControl x:Class="PopupTabbing.Page"
2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4:...
I've been fiddling with different approaches for implementing INotifyPropertyChanged. I blogged one approach awhile back, declaring my unhappiness with the pattern. Neil Mosafi also talked about how INotifyPropertyChanged might be an anti-pattern. I keep searching for a better way. At last night's Nerd Dinner, Brian Henderson was talking to Glenn Block and me about this problem. He suggested a language feature of some sort, with perhaps the feeling of generics. He mentioned that there really isn't anything to make properties easier, other than the automatic properties of C#, but those aren't very flexible. I crafted a syntax that...
Continuing my series of gotchas for Silverlight 2, I wanted to talk about a common error that people are seeing. This error is something new that you might see when moving code from Beta 2 to the Release Candidate or later. In Beta 2, if the layout engine detected a cycle, it didn't throw any errors; as I understand it, the layout was just aborted. But with post Beta2 bits, an error is thrown.
The error you'll get will specify "Layout Cycle Detected" as the message. This error message is very accurate--the layout engine detected a cycle within your layout; or...
As I'm sure you already know, a Release Candidate for Silverlight 2 was published. ScottGu does an amazing job of covering a lot of information in his blog posts, and others like Mike Snow have also provided some excellent detail. As they repeatedly told you, go check out the breaking changes document that lists all breaking changes from Beta2 to this release candidate.
If you have a Silverlight application that runs against Beta2, please take immediate action to get it moved (in a test environment) to the RC bits. There were a bunch of breaking changes (all for the better) and...
I stumbled upon some behavior awhile back that struck me as odd. I had a nullable property in my ViewModel that I was binding to in Silverlight, but I found that whenever the value was cleared out by the user, the property setter was not called. I narrowed it down to a simple application that has properties for Name and Age, as follows: 1: public string Name
2: {
3: ...
When creating a class that can be used with data binding, you have to implement the INotifyPropertyChanged interface. This interface requires that you have an event for PropertyChanged, specifying PropertyChangedEventArgs that provide the property name that was changed. Here’s what I mean: 1: public class Person : System.ComponentModel.INotifyPropertyChanged
2: {
3: private string _name;
4:
...
A little over a month ago, I announced that I was leaving BIG and relocating to Seattle. I think the blog post came out a bit somber, which wasn't necessarily intentional. Leaving BIG and the DASL project was certainly hard for me to do, so I think the tone was probably a subconscious leak of my sadness to walk away from something I liked so much. But I want to communicate firmly that I am very thankful for this opportunity to join Microsoft and work on the Silverlight framework. I am super-excited to have joined Microsoft; more so than I...
I have decided to leave Business Integration Group (BIG). I've been at BIG for a little over 5 years, and it's been a fantastic journey with them. I'm very happy at BIG and it was very difficult to decide to leave them. I've also thoroughly enjoyed the DASL project that I've been a part of for the majority of my tenure, and it will be difficult to walk away. To say that I've been happy at BIG is an understatement. It's a terrific place to work and the company is stacked full of some very smart people. It has...
Check out David Yardy's post that shows a chat we had about Silverlight. Technorati Tags: Silverlight