Silverlight Validators is not working in Custom control

Jan 24, 2010 at 7:06 PM

Silverlight validators is not working inside a custom control. I defined the default behavior of the custom control with silverlight validators as below in generic.xaml file. The Validator Base class looks for Base 'Usercontrol' type to find the validator manager. But for the custom control the base control will not be Usercontrol. Is there any work around fix for custom control? Any suggestions will be of great help.

<Style TargetType="timeline:TimelineCreateModifyEvents">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="timeline:TimelineCreateModifyEvents">                   
                    <StackPanel Width="400" x:Name="EventPanel" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
                        <Border VerticalAlignment="Center" Background="Black" Opacity="0.9" CornerRadius="10" BorderBrush="White" BorderThickness="1">
                            <Grid x:Name="LayoutRoot1" Margin="5,0,5,5">
                                <slv:ValidatorManager x:Name="EventGroup"></slv:ValidatorManager>
                                <TextBox Name="txtEventName" Text="{Binding Path=EventName}" Foreground="White" Height="28" Margin="4"
                                         Style="{StaticResource GlossyBlackTextBox}" VerticalAlignment="Center" Grid.Column="1" Grid.Row="4"
                                         TextWrapping="Wrap" Grid.ColumnSpan="5">
                                    <slv:ValidatorService.Validator>
                                        <slv:LengthValidator MinLength="1" MaxLength="99" ManagerName="EventGroup" IsRequired="True"
                                                             ErrorMessage="Invalid Event Name"/>
                                    </slv:ValidatorService.Validator>
                                </TextBox>
                            </Grid>
                        </Border>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>