Data Annotation Issue when Applying Style

3 posts, 0 answers
  1. bill
    bill avatar
    31 posts
    Member since:
    Sep 2007

    Posted 02 Mar 2010 Link to this post


      Was wondering if anyone may be able to help with this. Im new to the design side of silverlight and cant figure out why applying a style to a textbox caused the data annotations to stop working.

    I actually got this style from one of the Telerik demos and i really like it...hoping i can still use it!

    i tried the obvious of removing this or that but couldnt figure it out. the data annotations (validation in the setters) do not fire once it is applied

      <Style x:Key="DefaultTextBoxStyle" TargetType="TextBox">
            <Setter Property="FontSize" Value="11" />
            <Setter Property="FontFamily" Value="Arial" />
            <Setter Property="Foreground" Value="#FFFFFFFF" />
            <Setter Property="Template">
                    <ControlTemplate TargetType="TextBox">
                        <Grid x:Name="RootElement">
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="Normal" />
                                    <vsm:VisualState x:Name="MouseOver" />
                                    <vsm:VisualState x:Name="Disabled" />
                                    <vsm:VisualState x:Name="ReadOnly">
                                                <SplineDoubleKeyFrame KeyTime="0" Value="1" />
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Focused" />
                                    <vsm:VisualState x:Name="Unfocused" />

                                <Border x:Name="ReadOnlyVisualElement" Opacity="0"
                                        Background="#72F7F7F7" />
                                <Border BorderBrush="#FF017FDD" BorderThickness="1,1,1,1"
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FF032C58" />
                                            <GradientStop Color="#FF032854" Offset="0.61699998378753662" />
                                            <GradientStop Color="#FF072449" Offset="1" />
                                    <ScrollViewer x:Name="ContentElement" BorderThickness="0"
                                            IsTabStop="False" Padding="{TemplateBinding Padding}" />

  2. Pana
    Pana avatar
    748 posts

    Posted 05 Mar 2010 Link to this post

    Hi Bill,

    You are doing great with your xaml but the validation is a little tricky. Validation requires additional state group handling validation visual states. Also you need to add some visual elements to the template of the control to handle the visual presentation.

    I'm attaching the same template with the missing xaml code. It's working project so you can test, twist and bend and use the new template in your project.

    In addition - Expression Blend is really a great tool for front-end UI customization. Using blend you would be able to drag and drop TextBox from the toolbar, right click "Edit Template" and blend will generate all the template xaml for you. Than you can click around on a few color boxes to adjust colors and corner radiuses instead of typing XAML by hand.

    Hope the attached project will help you and thanks for testing our controls.

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. bill
    bill avatar
    31 posts
    Member since:
    Sep 2007

    Posted 05 Mar 2010 Link to this post


     Thank you very much for your time in helping me. Ill take a look at the attcahed project!

Back to Top