Archive

Posts Tagged ‘Visual State Manager’

Data Validation And Templating in Silverlight 4

July 25th, 2010 No comments

MiniTutorial

This is the fifth in a series on Templates and DataValidation.
[ First In Series Previous In Series ]

In this and the next posting I will create an application that will demonstrate how to modify the Visual State for invalid data. Along the way we will review:

  • Binding form elements to data
  • The binding engine and MVVM
  • Using the binding engine for data validation
  • Data validation and the Visual State Manager
  • Using the MVVM Light Toolkit
  • Best practices in application development
  • Creating Child Windows

Read more…

Teaching An Old Control New Tricks With Templates

July 17th, 2010 3 comments

MiniTutorial

This is the fourth in a short series on Templates and DataValidation.
[ First In Series    Previous In Series ]

You will remember that in the previous post in this small series, we created a new button template with a new appearance and new behavior for the “standard” view states. 

This button will be used with our form, and the form in turn will (eventually) be prepopulated from a database. It would be very convenient if the button reflected the need for the data to be saved when the user updates any of the fields.  The design calls for the button’s border to turn red when the user makes any changes, and to return to normal once the changes are saved. To jazz it up a bit, let’s have the button flash green on its way back to normal.

Read more…

Templates, Visual State and Fun With Controls

July 15th, 2010 No comments

This is the third (if you count Sunday’s update!) in my short series on Templates and Data Validation. [ First In SeriesPrevious In Series ] ClickButton Today we’re going to create a templated  Button that changes the appearance and visual state behavior of the button. Changing the visual state behavior in this case means responding to:

  • MouseOver, by swelling
  • MouseDown, by twisting and shrinking
  • Disable, by fading
  • Lost Focus and Get Focus (no change for this demo)

Read more…

Styles (followup)

July 11th, 2010 No comments

Yesterday’s post did not include source, and left fleshing out the styles as an exercise… this quick follow-up will provide a link to the full code and a quick walkthrough of the styles I ended up creating.

Read more…

Visual State Manager A-Z

July 9th, 2010 1 comment

Mini-tutorial

This is the first of a multipart series on the Visual State Manager which will cover

  • Styles
  • Resources
  • Templates
  • Custom Controls
  • Customizing data validation

Read more…

Animated Visual State Transitions with the Transitioning Content Control

April 29th, 2009 No comments

 

The Silverlight Toolkit is innovative in many ways, not least of which is that controls are released in one of four quality bands:

  • Mature: ready for release
  • Stable: suitable for most scenarios
  • Preview: suitable for most basic usage scenarios, may have moderate number of breaking changes as the control is developed.
  • Experimental: intended for evaluation purposes

The control I’ll be considering today was developed (and described here) by Ruurd Boeke and is currently in the Experimental band. You can expect that the API will change quite a bit, but that said, it is an enormously useful control right now; and thus I’ve submitted a video and this write-up.

What’s It For?

The goal of the Transitioning Content control is to make it easy to add animation when you are changing content within a control as demonstrated here. [You’ll need to click on DomainUpDown on the left (and surprisingly, not on TransitioningContent!) and Animations on top. The following cropped image illustrates where to click, but provides only a shadow of the impact

DemoTransition

Getting There In 3 Steps

To make this crystal clear, and to show how easy it really is to use this control, we’ll build the example three times: first with a Content Control, then with a Transitioning Content Control, and finally, adding data binding and the ability to transition more complex objects.

Starting Simple

Version 0 begins with a grid with two columns. The left column contains a ContentControl and the right a button. Here is the complete Xaml:

<UserControl x:Class="tccDemo.MainPage"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Width="300" Height="150">  <StackPanel Background="Bisque">

    <ContentControl x:Name="cc1"         Content="Click button to change."         HorizontalAlignment="Center"         Margin="20"         FontSize="18" />

    <Button x:Name="doChange"            Content="Change"            Width="80"            Height="30"            HorizontalAlignment="Center"            FontSize="14"/>    </StackPanel></UserControl>

The job of the ContentControl is to hold a single piece of content: in this case a string. The button’s job is to cause that content to change, which we do programmatically in the button’s click event handler in MasterPage.xaml.cs, shown in full:

using System;using System.Windows;using System.Windows.Controls;

namespace tccDemo{  public partial class MainPage : UserControl  {    public MainPage()    {      InitializeComponent();      doChange.Click += new RoutedEventHandler( doChange_Click );    }

    void doChange_Click( object sender, RoutedEventArgs e )    {      Random random = new Random();      cc1.Content = random.NextDouble().ToString();    }  }  // end class}    // end namespace

Each time the button is clicked, a new value is displayed.