This is a migrated thread and some comments may be shown as answers.

Data Annotation Issue when Applying Style

2 Answers 54 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
bill
Top achievements
Rank 1
bill asked on 02 Mar 2010, 11:21 PM
Hello,


  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">
            <Setter.Value>
                <ControlTemplate TargetType="TextBox">
                    <Grid x:Name="RootElement">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <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">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetName="ReadOnlyVisualElement"
                                                Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused" />
                                <vsm:VisualState x:Name="Unfocused" />
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

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

2 Answers, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 05 Mar 2010, 12:29 PM
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.

Greetings,
Panayot
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.
0
bill
Top achievements
Rank 1
answered on 05 Mar 2010, 07:13 PM
Panayot,

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

Bill
Tags
General Discussions
Asked by
bill
Top achievements
Rank 1
Answers by
Pana
Telerik team
bill
Top achievements
Rank 1
Share this question
or