Silverlight

There are 57 entries for the tag Silverlight
WCF RIA Services V1.0 SP2 Released

On December 9, 2011, Silverlight 5 was released.  As always, RIA Services is included in the Tools for Silverlight, and this new release included our V1.0 SP2 final build.  We refer to this as our RTW build, meaning Released-To-Web.  In addition to the Tools installer including WCF RIA Services V1.0 SP2, you can also find the standalone installer on Microsoft Download Center.  The silverlight.net/getstarted/riaservices page was also updated to reflect the new release. Aside from some bug fixes here and there, not much changed between SP2 RC and SP2 RTW.  The primary focus as been ensuring really solid compatibility...

posted @ Monday, December 12, 2011 11:04 PM | Feedback (8)

RIA Services Validation: Available on GitHub

I’ve gotten quite a few requests for the source code behind the RIA Services Validation blog post series.  I am pleased to announce that the code is now published on GitHub. http://github.com/jeffhandley/RIAServicesValidation Within that repository, you’ll find: RudeValidation.Web/Models – Server-side model classes RudeValidation.Web/Validators – Custom validators including CompareValidator, ConditionallyRequired, and DateValidator RudeValidation/Views – Sample screens showing the validation in action RudeValidation/ViewModels - Where you’ll find the sample ViewModel as well as the very simple ViewModelBase If you’re not familiar...

posted @ Tuesday, September 6, 2011 11:50 PM | Feedback (2)

RIA Services Validation: ViewModel Validation with Entity Rules

For those of you familiar with the ViewModel (or MVVM) pattern, you are likely also familiar with a typical pain point regarding validation: you often need to duplicate your entity validation metadata onto your ViewModel classes.  This can lead to burdensome dual maintenance of your validation rules, and it can seem very frustrating that with the server to client metadata propagation that RIA Services offers, your ViewModel classes are left dangling out there for you to manage yourself.  In this post, I’ll illustrate a utility I created that allows a ViewModel to assume validation metadata from model classes or properties,...

posted @ Tuesday, September 6, 2011 11:31 PM | Feedback (5)

Business Application Project Login / Registration Disables Everything

There is a known issue with WCF RIA Services V1.0 SP2 RC’s Business Application project template.  The issue only surfaces in Silverlight 5, and there’s an easy way to fix it.  We determined the root cause of this issue after it was too late to fix it in time for the RC release, but the correction is in place for the RTW (final) release of SP2. This bug surfaces after you create a new project after installing RIA Services SP2, using the Business Application project template, and then an end user registers or logs in.  After completing the registration/login...

posted @ Saturday, September 3, 2011 3:42 PM | Feedback (5)

WCF RIA Services V1.0 SP2 RC

On September 1, 2011, Silverlight 5 RC was released.  As always, RIA Services is included in the Tools for Silverlight, and that release included our V1.0 SP2 RC build.  And also as always, we published a standalone installer for RIA Services.  You can find it on the download center.  The silverlight.net/getstarted/riaservices page will get updated soon to include the link to this build. This release is one more step toward closing down our SP2 release, and we fixed a number of bugs since SP1.  Some notable differences between SP1 and SP2 are: DateTimeOffset is supported...

posted @ Friday, September 2, 2011 6:25 PM | Feedback (11)

WCF RIA Services - MIX11 Releases

This week at MIX, the RIA Services team has put out two releases: WCF RIA Services V1.0 SP2 Preview (April 2011) Download available here.  This MSI is also included with the Silverlight 5 Beta Tools. Note: you cannot have both SP1 and SP2 installed on your machine.  Installing SP2 will upgrade your machine from SP1 to SP2. This is a Preview-quality release and does not include a Go-Live license.  Here’s what you’ll find within this release: Support for Silverlight 5 Beta - SP1 does not properly perform code generation when...

posted @ Wednesday, April 13, 2011 11:40 AM | Feedback (8)

WCF RIA Services Toolkit December 2010

Up until now, the WCF RIA Services team has always published 2 installers with each release: The actual “Product” bits – What gets installed as WCF RIA Services (with a specific version number) The additional “Toolkit” bits – What gets installed as WCF RIA Services Toolkit The Product installer is where our official product features reside.  This includes our core .NET and Silverlight assemblies such as the LinqToEntitiesDomainService and the Silverlight DomainDataSource control.  The Toolkit is where we’ve put features that we want to distribute but that don’t (yet?) make the...

posted @ Thursday, December 2, 2010 8:59 AM | Feedback (3)

RIA Services Validation: Video Tutorials (in VB)

Not too long ago, a gentleman named Bill Burrows (a VB MVP) contacted me and asked for permission to use content from my blog to create a video tutorial series on RIA Services Validation.  I was really flattered by this and gave him my permission.  I apply a Creative Commons Share-Alike license to the content on my blog, so Bill could have really done this without my explicit permission, but I do appreciate that he asked.  I simply requested that he respect the Share-Alike and Attribution portions of the license. Today, Bill sent me an update to let me...

posted @ Friday, November 19, 2010 9:43 PM | Feedback (0)

RIA Services Validation: Using ValidationContext (Cross-Entity Validation)

In our last post, we learned how ValidationContext can be used to provide and consume state and services for validation methods to use.  Now, let’s take a quick look at how validation methods can actually use this information.  I’m going to include a bunch of code in this post, and I will rely on the code to be rather self-explanatory. Property-Level Validation In this property-level validation example, we need to validate that the location entered for a meeting is a valid location from our database.  We want this to work both on the server and on the client,...

posted @ Monday, October 25, 2010 1:56 AM | Feedback (20)

RIA Services Validation: Providing ValidationContext

Throughout this series on RIA Services Validation, I’ve mentioned and shown ValidationContext several times.  In this post, we’ll learn about the purpose of ValidationContext, what types of context it can provide, and how it integrates with RIA Services.  This will allow us to explore further topics such as cross-entity validation and open the door for other advanced validation scenarios. ValidationContext Purpose Although ValidationContext exists within the System.ComponentModel.DataAnnotations assembly in both .NET 4.0+ and Silverlight 3+, the class was introduced by the RIA Services team.  While designing the RIA Services validation system, we considered scenarios where validation logic is...

posted @ Monday, October 25, 2010 12:49 AM | Feedback (7)

RIA Services Validation: Entity-Level Validation

In my last post, I went over some cross-field validation scenarios and provided some sample code, including a CompareValidatorAttribute.  We’ve now covered single-field validation and cross-field validation, but there’s yet another level of validation supported by RIA Services—Entity-Level validation.  As you’ll see in this post, entity-level validation is very similar to what we’ve already seen. Entity-Level Validation Declaration Your entity types can declare entity-level validation using either the [CustomValidation] attribute approach where a custom validation method is supplied, or by having an attribute that derives from ValidationAttribute.  Either way, to indicate that a validation rule applies at the...

posted @ Tuesday, October 12, 2010 1:31 AM | Feedback (7)

RIA Services Validation: Cross-Field Validation

I frequently hear questions about how to perform cross-field validation in RIA Services.  Before thoroughly covering this topic*, I wanted to be sure to go through some simple scenarios, show how to use CustomValidationAttribute, how to derive from ValidationAttribute, explain how validation rules are propagated to the client, and what triggers the validation.  Hopefully by now, you’re getting pretty comfortable with the validation framework and you’re ready to explore some more examples. * Perhaps you noticed that I snuck a reusable cross-field validator into the Custom Reusable Validators post—it’s a rather useful ConditionallyRequiredAttribute. In this post, I’m going...

posted @ Sunday, October 10, 2010 1:29 AM | Feedback (4)

RIA Services Validation: Validation Triggers

My goal with this blog post series is to provide an end-to-end tour of how RIA Services validation works and how you can leverage its capabilities to build rich, responsive applications.  A key factor for making the most of validation is fully understanding when and how RIA Services invokes your validation rules.  Awareness of the various validation triggers will help you implement your validators so they are fired as you expect, when you expect.  In this post will dig into the RIA Services codebase and identify every place where entity validation is invoked. Client-Side Validation Property Setters –...

posted @ Wednesday, October 6, 2010 3:48 AM | Feedback (2)

RIA Services Validation: Attribute Propagation

Since the beginning of the RIA Services project, a primary tenet was to propagate validation rules defined on the server up to the client, integrating the validation directly into the Silverlight UI.  This came to fruition with RIA Services v1.0 and you can in fact apply an attribute to your model on the server and automatically get instant client-side validation of data entry on even the simplest of Textbox controls.  In fact, some validation rules are inferred from your data model directly.  This is a feat that many other frameworks have attempted to accomplish, but I believe RIA Services has...

posted @ Thursday, September 30, 2010 2:37 AM | Feedback (2)

RIA Services Validation: Custom Reusable Validators

We just covered Custom Validation Methods, where we learned how to use CustomValidationAttribute to invoke a static (VB: Shared) method to perform validation.  Let’s talk about an alternate approach to custom validation though: creating custom, reusable validators by deriving from ValidationAttribute.  While it’s true that the custom validation methods used by [CustomValidation] could certainly be reusable, I tend to think of that approach as a light-weight way to call specific business logic routines for validation.  The approach we’re about to see is what I use when I’m creating an inventory of validators to be reused throughout my project(s). Deriving...

posted @ Sunday, September 26, 2010 3:39 AM | Feedback (7)

RIA Services Validation: Custom Validation Methods

In our last installment, we learned about the standard validators that ship in the System.ComponentModel.DataAnnotations assembly.  RequiredAttribute, RangeAttribute, StringLengthAttribute, and RegularExpressionAttribute all derive from ValidationAttribute and cover many common validation scenarios.  Every system has its own business rules though, and therefore it’s imperative that RIA Services allows you to create custom validators to implement your own logic.  Moreover, your custom error messages must plug into the same framework that powers the standard validators.  To address this requirement, we added CustomValidationAttribute. Using CustomValidationAttribute to Invoke a Method System.ComponentModel.DataAnnotations.CustomValidationAttribute allows you to easily redirect a validator to a method you’ve...

posted @ Saturday, September 25, 2010 11:12 PM | Feedback (2)

RIA Services Validation: Standard Validators

RIA Services offers powerful features for flowing validation from your entity model all the way up to the Silverlight UI.  In fact, flowing your validation rules from the server into your form controls was one of the primary tenets of RIA Services V1, and our team did the work of getting validation integrated deeply into Silverlight, long before RIA Services was released.  In this post we’ll take a look at the standard validators that are offered. System.ComponentModel.DataAnnotations.ValidationAttribute RIA Services employs the ValidationAttribute class from System.ComponentModel.DataAnnotations for defining validation rules on your entity model.  ValidationAttribute itself is abstract (VB:...

posted @ Wednesday, September 22, 2010 3:16 AM | Feedback (4)

DomainDataSource, ComboBox, and Load Blocking

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...

posted @ Tuesday, June 22, 2010 2:36 AM | Feedback (9)

Async Validation with RIA Services

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...

posted @ Wednesday, May 26, 2010 1:06 PM | Feedback (32)

RIA Services - Documentation Guidance and Community Samples

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...

posted @ Tuesday, March 30, 2010 7:20 PM | Feedback (11)

DomainDataSource Filters and Parameters

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...

posted @ Monday, March 15, 2010 7:24 PM | Feedback (26)

ContosoSales Application for RIA Services RC

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...

posted @ Monday, March 15, 2010 1:20 PM | Feedback (7)

ValidationResult - Specifying Member Names

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...

posted @ Wednesday, February 24, 2010 11:42 PM | Feedback (7)

DomainDataSource Error Handling

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...

posted @ Thursday, November 19, 2009 8:29 PM | Feedback (21)

Building ContosoSales - The RIA Services Keynote Demo

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...

posted @ Wednesday, November 18, 2009 10:04 AM | Feedback (16)

DomainDataSourceView API (DomainDataSource.DataView)

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,...

posted @ Monday, November 16, 2009 3:58 PM | Feedback (4)

DomainDataSource DataPager PageSize Pitfall

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...

posted @ Monday, November 16, 2009 3:12 AM | Feedback (5)

DomainDataSource – Single Record Results

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: ...

posted @ Tuesday, November 10, 2009 10:33 AM | Feedback (2)

Validating Objects and Properties with Validator

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...

posted @ Friday, October 16, 2009 5:40 PM | Feedback (16)

Add/Remove with DataForm and RIA Services

Note: The limitations discussed herein no longer apply once you get WCF RIA Services V1 SP1 Beta (or later). See Kyle McClellan's blog for more info. 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,...

posted @ Friday, August 14, 2009 1:50 AM | Feedback (30)

Sharing Source with Silverlight

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...

posted @ Wednesday, August 12, 2009 9:10 AM | Feedback (1)

Not Breaking on ValidationException (take 2)

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...

posted @ Friday, August 7, 2009 7:44 PM | Feedback (6)

DomainDataSource.DataView

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,...

posted @ Tuesday, July 21, 2009 5:41 PM | Feedback (3)

DomainDataSource – Defining Its Limits

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...

posted @ Tuesday, July 14, 2009 3:45 AM | Feedback (15)

Async Validation with .NET RIA Services and DataForm

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 week.  The result is...

posted @ Saturday, July 11, 2009 5:05 AM | Feedback (9)

Validating Decimal Ranges with RangeAttribute

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: ...

posted @ Thursday, July 9, 2009 2:39 PM | Feedback (0)

Validation Exceptions in Silverlight

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...

posted @ Wednesday, April 1, 2009 10:33 AM | Feedback (6)

.NET RIA Services – Implementing Custom Interfaces

.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...

posted @ Monday, March 30, 2009 1:49 PM | Feedback (6)

Shipping Software

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...

posted @ Wednesday, March 18, 2009 4:41 PM | Feedback (0)

Silverlight 3 and .NET RIA Services

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...

posted @ Wednesday, March 18, 2009 1:10 PM | Feedback (0)

Silverlight Airlines with a ViewModel

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. ...

posted @ Friday, November 14, 2008 2:22 PM | Feedback (5)

Silverlight Control Template Doesn’t Get Applied

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:  ...

posted @ Wednesday, October 29, 2008 6:15 PM | Feedback (6)

Binding Converters - VisibilityConverter

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...

posted @ Monday, October 27, 2008 9:58 PM | Feedback (1)

HelloWorld.ViewModel

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; ...

posted @ Monday, October 27, 2008 11:08 AM | Feedback (14)

ViewModel Pattern

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,...

posted @ Tuesday, October 21, 2008 4:31 PM | Feedback (5)

Silverlight 2 RTW

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...

posted @ Tuesday, October 14, 2008 12:44 AM | Feedback (0)

Silverlight 2 Gotcha - Tab Navigation in a Popup, Take 2

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: ...

posted @ Thursday, October 9, 2008 10:54 AM | Feedback (3)

INotifyPropertyChanged - Extension Methods

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 ...

posted @ Tuesday, October 7, 2008 9:05 PM | Feedback (5)

Silverlight 2 Gotcha - Tab Navigation in a Popup

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:...

posted @ Tuesday, October 7, 2008 8:44 PM | Feedback (3)

INotifyPropertyChanged -- Searching for a Better Way

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...

posted @ Tuesday, October 7, 2008 5:02 PM | Feedback (2)

Silverlight 2 Post Beta2 Gotcha - Layout Cycle Detected

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...

posted @ Friday, September 26, 2008 9:46 AM | Feedback (1)

Silverlight 2 Post Beta2 Gotcha - ContentPresenter

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...

posted @ Thursday, September 25, 2008 11:37 PM | Feedback (0)

Binding to Nullable Values in XAML

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: ...

posted @ Wednesday, July 9, 2008 2:07 PM | Feedback (15)

Property Changed Events

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:  ...

posted @ Thursday, June 19, 2008 1:47 PM | Feedback (4)

Life.Reboot()

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...

posted @ Monday, May 12, 2008 6:06 PM | Feedback (1)

Leaving BIG and Relocating

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...

posted @ Sunday, April 6, 2008 1:39 PM | Feedback (2)

Business Web Applications and Porn Sites

Check out David Yardy's post that shows a chat we had about Silverlight. Technorati Tags: Silverlight

posted @ Friday, January 25, 2008 2:59 PM | Feedback (2)