Skip to content

Instantly share code, notes, and snippets.

@nseba
Created October 12, 2012 10:05
Show Gist options
  • Save nseba/3878517 to your computer and use it in GitHub Desktop.
Save nseba/3878517 to your computer and use it in GitHub Desktop.
Validation Control
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Views="using:Byteflux.Views">
<SolidColorBrush x:Key="ValidationErrorBrush" Color="Orange"/>
<Style x:Key="ValidationTextStyle" TargetType="TextBlock" BasedOn="{StaticResource ItemTextStyle}">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Foreground" Value="{StaticResource ValidationErrorBrush}"/>
</Style>
<Style TargetType="Views:ValidationResultPlaceholder">
<Setter Property="Margin" Value="0,10,0,10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Views:ValidationResultPlaceholder">
<ItemsControl ItemsSource="{TemplateBinding Content}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Style="{StaticResource ValidationTextStyle}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
namespace Byteflux.Views
{
using Windows.UI.Xaml.Controls;
public sealed class ValidationResultPlaceholder : ContentControl
{
public ValidationResultPlaceholder()
{
DefaultStyleKey = typeof(ValidationResultPlaceholder);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment