Click here to Skip to main content
15,881,803 members
Articles / Desktop Programming / WPF

Validizor - A Validation Control for WPF

Rate me:
Please Sign up or sign in to vote.
4.66/5 (16 votes)
17 Oct 2007CPOL7 min read 94.4K   4.3K   58  
A WPF validation control for validating your data objects.
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:lib="clr-namespace:Microsoft.Samples.KMoore.WPFSamples.Zap"
    >

  <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" x:Key="pageButtonStyle">
    <Setter Property="Width" Value="30" />
    <Setter Property="Height" Value="30" />
  </Style>

  <Style TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource {x:Type RepeatButton}}" x:Key="pageRepeatButtonStyle">
    <Setter Property="Width" Value="30" />
    <Setter Property="Height" Value="30" />
    <Setter Property="Interval" Value="500" />
  </Style>

  <Style TargetType="{x:Type ItemsControl}" x:Key="ZapScrollItemNavItemsControlStyle">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ItemsControl}">
          <StackPanel Orientation="Horizontal" IsItemsHost="True"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="ItemTemplate">
      <Setter.Value>
        <DataTemplate>
          <Button Command="{Binding }" Style="{StaticResource pageButtonStyle}" Content="{Binding Path=Number}"/>
        </DataTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type lib:ZapScroller}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type lib:ZapScroller}">
          <DockPanel>
            <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" HorizontalAlignment="Center" >
              <Button Content="&lt;&lt;" Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FirstCommand}"
                      Style="{StaticResource pageButtonStyle}"
                      />
              <RepeatButton Content="&lt;" Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PreviousCommand}"
                            Style="{StaticResource pageRepeatButtonStyle}"
                      />

              <ItemsControl ItemsSource="{TemplateBinding Commands}" Style="{StaticResource ZapScrollItemNavItemsControlStyle}"
                          />

              <RepeatButton Content="&gt;" Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NextCommand}"
                            Style="{StaticResource pageRepeatButtonStyle}"
                      />
              <Button Content="&gt;&gt;" Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=LastCommand}"
                      Style="{StaticResource pageButtonStyle}"/>
            </StackPanel>

            <lib:ZapDecorator Name="PART_ZapDecorator"/>
          </DockPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type lib:ZapItemsControl}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type lib:ZapItemsControl}">
          <lib:ZapScroller>
            <lib:ZapPanel IsItemsHost="true" />
          </lib:ZapScroller>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>

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 Code Project Open License (CPOL)


Written By
Software Developer
United States United States
software engineer

Comments and Discussions