views:

44

answers:

1

Hi
I wrote simple template in xaml for button s.(for silver-light 4)
So when I try use "ControlTemplate.Triggers", I found that is impossible in silver-light, and we must use Visual-State in Silver-Light
so I wrote first ControlTemplate with Visual-State but it not work fine.(here is code)

 <Style x:Key="NextButtonStyle" TargetType="Button">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid x:Name="MainGrid">
                        <Border x:Name="MainBorder"
                                BorderThickness="2"
                                BorderBrush="#FFC0C0C0"
                                Background="Bisque"
                                CornerRadius="4 4 4 4" >
                            <TextBlock x:Name="lbl"
                                       VerticalAlignment="Center"
                                       HorizontalAlignment="Center"
                                       Text=">"
                                       Foreground="#FFC0C0C0"
                                       FontWeight="Bold"
                                       FontFamily="TimesNewRoman"
                                       FontSize="15"/>
                        </Border>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames AutoReverse="False" Duration="00:00:00.2"
                                                                      Storyboard.TargetName="MainBorder"
                                                                      Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color}">
                                            <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF606060"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames AutoReverse="False" Duration="00:00:00.2"
                                                                      Storyboard.TargetName="lbl"
                                                                      Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color}">
                                            <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF606060"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>

                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

When i use this style and move on this border this border, both of border and textbloc became invisible. so
1) What do i do?
2) and is there any good examples for Visual-State

A: 

Because of two simple mistakes u r style was not working , else all is right.

1)Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color}

It will be : Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)

2) The same goes for the textblock : Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color}

It will be : Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)

Malcolm
so foolish mistake! `thanks for great help` is there any good article about Visual-State
Rev
As far as i know there is no such a good article provided. But i will give you my opinion, what i did when i was new to visual state. Just install expression blend - the expression blend generates all the vsm automatically for you. Then just edit the vsm, play with its properties, state overs maually.http://expression.microsoft.com/en-us/cc197141.aspx
Malcolm
So good tip 'expression blend'. I have that ,but i don't know how work with that (specially for creating animations, effects and Visual-State) how can I access to good guide about Blend 3.
Rev
http://msmvps.com/blogs/theproblemsolver/archive/2009/02/17/changing-the-mouseover-effect-on-a-silverlight-listbox.aspxThe above link is the one which helped me to get started with blend.It speaks about styling the listbox, and this is the best example where you will cover all the states.
Malcolm
After bashing my head against trying to do design and animation in Visual Studio I'm just going to add a bit more weight to the Blend chorus. Silverlight (especially for animation and design) is made for Blend. It's a bit of a learning curve but absolutely worth it.
Doobi
@Doobi right said....worth it..:)
Malcolm