Silverlight 3 style and control template (XAMLSL3StyleControlTemplate)

This XAML sample demonstrates how to work with Style and ControlTemplate in Silverlight 3.

C# (49.1 KB)
 
 
 
 
 
(0)
9,595 times
Add to favorites
5/5/2011
E-mail Twitter del.icio.us Digg Facebook
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="XAMLSL3StyleControlTemplate.App"
             >
    <Application.Resources>
		<Style x:Key="NoBorderTextBoxStyle" TargetType="TextBox">
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="Background" Value="#FFFFFFFF"/>
			<Setter Property="Foreground" Value="#FF000000"/>
			<Setter Property="Padding" Value="2"/>
			<Setter Property="BorderBrush">
				<Setter.Value>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFA3AEB9" Offset="0"/>
						<GradientStop Color="#FF8399A9" Offset="0.375"/>
						<GradientStop Color="#FF718597" Offset="0.375"/>
						<GradientStop Color="#FF617584" Offset="1"/>
					</LinearGradientBrush>
				</Setter.Value>
			</Setter>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="TextBox">
						<Grid x:Name="RootElement">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Disabled"/>
									<VisualState x:Name="ReadOnly"/>
								</VisualStateGroup>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused"/>
									<VisualState x:Name="Unfocused"/>
								</VisualStateGroup>
								<VisualStateGroup x:Name="ValidationStates">
									<VisualState x:Name="Valid"/>
									<VisualState x:Name="InvalidUnfocused"/>
									<VisualState x:Name="InvalidFocused"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<ScrollViewer x:Name="ContentElement" BorderThickness="0" IsTabStop="False" Padding="{TemplateBinding Padding}" Margin="1,1,3,-1"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</Application.Resources>
</Application>