Click here to Skip to main content
15,896,730 members
Articles / Programming Languages / C# 4.0

RiaTasks: Central Silverlight Business Rules Validation

Rate me:
Please Sign up or sign in to vote.
4.98/5 (28 votes)
13 Jul 2010Ms-PL4 min read 80.3K   781   43  
Using Fluent Validation on the website to validate business rules in a Silverlight application
<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:RIATasks"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
	mc:Ignorable="d"
	x:Class="RIATasks.TaskDetails"
	d:DesignWidth="330" d:DesignHeight="258">
	<UserControl.DataContext>
		<local:TaskDetailsModel/>
	</UserControl.DataContext>

	<Grid x:Name="LayoutRoot" >
		<Grid.RowDefinitions>
			<RowDefinition Height="0.802*"/>
			<RowDefinition Height="0.198*"/>
		</Grid.RowDefinitions>
		<Grid x:Name="TaskDetails1" d:DataContext="{d:DesignData /SampleData/TaskDetailsModelSampleData.xaml}" Visibility="{Binding HasCurrentTask}" Grid.RowSpan="2">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="0.328*"/>
				<ColumnDefinition Width="0.672*"/>
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="0.143*"/>
				<RowDefinition Height="0.671*"/>
				<RowDefinition Height="0.186*"/>
			</Grid.RowDefinitions>
			<TextBlock TextWrapping="Wrap" Text="Name:" VerticalAlignment="Top" HorizontalAlignment="Right" FontSize="16" Margin="0,0,5,0" Foreground="{StaticResource Brush1}"/>
			<TextBox Grid.Column="1" TextWrapping="Wrap" FontSize="16" VerticalAlignment="Top" Text="{Binding CurrentTask.TaskName, Mode=TwoWay}" Height="30" />
			<TextBlock Grid.Row="1" TextWrapping="Wrap" Text="Description:" HorizontalAlignment="Right" FontSize="16" VerticalAlignment="Top" Margin="0,5,5,0" Foreground="{StaticResource Brush1}"/>
			<TextBox Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding CurrentTask.TaskDescription, Mode=TwoWay}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
			<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top"/>
			<TextBlock Grid.Row="2" TextWrapping="Wrap" Text="Due Date:" HorizontalAlignment="Right" FontSize="16" Foreground="{StaticResource Brush1}" d:LayoutOverrides="Height" VerticalAlignment="Center"/>
			<TextBox Grid.Column="1" TextWrapping="Wrap" FontSize="16" VerticalAlignment="Center" Text="{Binding DueDate, Mode=TwoWay, ValidatesOnDataErrors=True, StringFormat='MM/dd/yyyy'}" Height="30" Grid.Row="2" />
		</Grid>
	</Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior) http://ADefWebserver.com
United States United States
Michael Washington is a Microsoft MVP. He is a ASP.NET and
C# programmer.
He is the founder of
AiHelpWebsite.com,
LightSwitchHelpWebsite.com, and
HoloLensHelpWebsite.com.

He has a son, Zachary and resides in Los Angeles with his wife Valerie.

He is the Author of:

Comments and Discussions