Tag Archives: xaml

Using RIA Services Programmatically

Many demos of WCF RIA Services show off using the DomainDataSource Class to in a declarative manner to quickly throw together a data-enabled application. And in VS2010, there is added support for using the Data Sources Window to Drag/Drop data entities onto the designer — this action also adds a DomainDataSource instance into your XAML. For many applications, using a DomainDataSource in XAML is fine and enables RAD development. But some pundits (Hi Shawn!) argue that having direct interaction with the Data Layer from the UI Layer is bad for proper Model/View separation, testability, and general karma. Luckily, there are several ways to use WCF RIA Services programmatically - without relying on the DomainDataSource controls in XAML. Let’s take a look at some of these programmatic methods: Download the Demo Code   * requires SL4/VS2010 Beta 2 , WCF RIA Services Beta Using the DomainContext The DomainContext class allows the Silverlight client to access the Domain Service Class you created on the server side. A new DomainContext class is automatically generated on the client side for you when you create a new Domain Service. In the demo , our DomainContext class is named BeerContext

Excerpt from:
Using RIA Services Programmatically

RIA Services Talk at CNY .NET Dev Group

Thanks to everyone who attended my WCF RIA Services talk at the CNY .NET Developer Group in Syracuse, NY! In this talk we used Visual Studio 2010 Beta 2 and WCF RIA Services Beta to develop a line of business application centered around (what else) Beers! If you are in the Rochester, NY area, I’ll be repeating this presentation at the Visual Developers of Upstate NY group on Wednesday, January 27th. Download the Demo     * requires SL4/VS2010 Beta 2 , WCF RIA Services Beta Download the Slides I had mentioned in the talk that I ran out of time and didn’t get to cover the Programmatic Use of WCF RIA Services, and so I have posted that in this separate blog entry .  

See original here:
RIA Services Talk at CNY .NET Dev Group

Silverlight 3 - MergedDictionaries

After having worked a while with Silverlight you realize that you often keep a lot of things in resources in your Xaml. Not only do you add Storyboards for your animations, but you often also add styles and templates, and some converters and so on. The resources all of the sudden start taking up most if the rows in your Xaml. It becomes hard to read. It is also hard to share resources. Say that you have these converters that you use in several of your controls

Read the original post:
Silverlight 3 - MergedDictionaries

Silverlight Wrap Panel

Wrap panel in Silverlight is missing out of the box, but this need is fulfilled by Silverlight Toolkit which also includes many other controls. In this post we will look at WrapPanel. I will show you how to use it and what it is used for. To use wrap panel you have to install Silverlight Toolkit . Once installed, you will need to add a reference to Silverlight.Windows.Controls.Toolkit   And you can now use the WrapPanel. In the XAML below you can see that the main container of my user co

Continued here:
Silverlight Wrap Panel

RIA Services Domain Data Source Invalid Property Errors

Silverlight 3 has made it a little easier to pin point these types of errors but it can still be complex at times.  One of those times is when the invalid property is on the DomainContext of your .NET RIA Services DomainDataSource control.  You might see it getting this type of AG_E_PARSER_BAD_PROPERTY_VALUE exception.    If taking the line number to the XAML file along with the position indicates it’s the DomainContext property that’s where it gets interesting.  I’ve been caught in t

Continued here:
RIA Services Domain Data Source Invalid Property Errors

Wanted: XAML for Spatially Enabled Workflows

After working with XAML for a couple of months now, I’m shifting gears to enhance a data exporter I wrote several years ago. I sure wish there were examples of spatially enabled Windows Workflow Foundation (WF) applications for this sort of thing. The glamor of Silverlight/WPF is overshadowing a lot of useful things XAML offers for workflow. David Chappell has a good overview of WF here . Indeed, it seems like XAML could be used to implement a lot of the vision outlined by Paul Torrens

See the original post: 
Wanted: XAML for Spatially Enabled Workflows

Dispatcher and Multi-threading in Silverlight3

In Silverlight3, as with WinForms and WPF,  we need to be careful about cross thread communication. Controls instantiated in the XAML DOM belong to the UI thread and only the UI thread can update them. To see this, try updating the UI from a different thread, public MainPage() { InitializeComponent();   // Explicitly start a new thread, Thread myThread = new Thread (FillRectangle); myThread.Start(); }   void FillRectangle() { // Try to update the UI

View post: 
Dispatcher and Multi-threading in Silverlight3

Commands in Prism and MVVM

Here is one video of Erik Mork who explains how commanding works in Prism and MVVM .   Prism Commands allow designers/develops to specify, in XAML, events that fire back into the ViewModel/Presenter. Imagine this: the user hovers a mouse over a Silverlight control. Commanding allows that action to be bound to a method (more specifically, a delegate) in the ViewModel. The ViewModel is then able to handle that action.

Read more: 
Commands in Prism and MVVM

From Silverlight in Action 2nd Edition: UI Element Binding

One reason I’ve been so quiet over the past couple months, is I have been scrambling to update Chad Campbell and John Stockton’s excellent Manning Silverlight 2 in Action book to Silverlight 3, under the title Silverlight in Action 2nd Edition (the Amazon info is out of date), to be released this fall. I’ve done a little restructuring (but not a ton) in the process, and have also been covering as many new Silverlight 3 goodies as I can, as well as a couple extras like ViewModel and .NET RIA Services. I just finished writing the section about UI Element binding in Silverlight 3, and thought I’d share some of the pre-edited version with you all, since the example here solves something I’m often asked to do in Silverlight applications. Enjoy! As a reminder, Manning Early Access Program (MEAP) members will be getting chapters of the book in the next couple days, with a much larger release of content just after Silverlight 3 goes live. If you’re looking to get an edge up on Silverlight 3, I’d definitely recommend joining MEAP . 7.2.3 Binding to a UI element Binding one or more properties of a UI Element to values on an entity, ViewModel or business object is certainly a compelling use of binding. Sometimes, though, you want to use binding for things we wouldn’t traditionally consider “data”, things within the user interface. You may want to bind the height of two controls together so that they resize equally, or perhaps you want to bind three sliders to the x, y, and z-axis rotations respectively of a plane (see chapter n for more information on 3d rotation in Silverlight). Rather than binding to gather input or display data to the user, you’re binding to avoid writing extra plumbing code. Let’s say that you want to display a count of characters entered into a TextBox in real-time. Something like the figure below. You could certainly do that in code, but that would be fairly uninteresting code to write, and would need to refer to XAML elements by name, or have event handlers wired in XAML, introducing a dependency on the specific page’s code-behind and making it less portable and potentially more brittle. In addition, you’d find yourself doing it enough that you’d either wrap the TextBox in your own CountingCharsTextBox control, or add a helper buddy class or something. Or, if you prefer a XAML approach, which I hope I’ve sold you on by now, Silverlight 3 introduced the concept of Element Binding. Element Binding allows you to bind the properties of one FrameworkElement to another FrameworkElement. The usual restrictions apply (target must be a DependencyProperty, source must notify of changes) so you cannot using element binding quite everywhere. To produce the above TextBox with the automatic count of characters using Element Binding, the markup is pretty straight-forward and entirely self-contained: The above XAML will show a TextBox with a count of characters underneath it. The character count will update in real-time to show the number of characters typed into the TextBox. Note also that the MaxLength displayed under the textbox is actually coming from the TextBox itself (the 140 in the label is not, however). The key item that makes this happen is the ElementName parameter in the binding expression. ElementName is, as it suggests, the name of another element on the XAML page.

More: 
From Silverlight in Action 2nd Edition: UI Element Binding

6 New Silverlight Image Rotators

After working for one whole day, I have created another 4 image rotators. We have all together 6 image rotators now! All image rotators are redesigned such that they can be reused easily using XAML.

Read the rest here:
6 New Silverlight Image Rotators