1

ボタンs用にxamlで単純なテンプレートを作成しました(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
ので、最初にVisual-Stateを使用してControlTemplateを作成しましたが、正常に機能しません(コードはこちら)。

 <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>

このスタイルを使用してこの境界線をこの境界線上に移動すると、境界線とテキストブロックの両方が非表示になりました。だから
1)私は何をしますか?
2)そしてVisual-Stateの良い例はありますか

4

1 に答える 1

0

2つの単純な間違いのために、私たちのスタイルは機能していませんでした。そうでなければ、すべてが正しいです。

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

次のようになります:Storyboard.TargetProperty = "(Border.BorderBrush)。(SolidColorBrush.Color)

2)同じことがテキストブロックにも当てはまります:Storyboard.TargetProperty = "(TextBlock.Foreground)。(SolidColorBrush.Color}

次のようになります:Storyboard.TargetProperty = "(TextBlock.Foreground)。(SolidColorBrush.Color)

于 2010-06-28T07:26:07.170 に答える