Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hyperlink Silverlight 5超链接更改样式基于相同的基础样式但前景不同_Hyperlink_Silverlight 5.0_Base_Foreground - Fatal编程技术网

Hyperlink Silverlight 5超链接更改样式基于相同的基础样式但前景不同

Hyperlink Silverlight 5超链接更改样式基于相同的基础样式但前景不同,hyperlink,silverlight-5.0,base,foreground,Hyperlink,Silverlight 5.0,Base,Foreground,我正在尝试为超链接控件设置不同的样式。新样式基于与前一样式相同的基础样式,前一样式设置为“控件”,并且“前景”属性已覆盖为新颜色。 但在应用上前景并没有改变 几点注意: 如果覆盖属性为FontSize,则一切正常。 在Silverlight 4中,一切正常。 如果我删除BasedOn属性(不从基类派生),一切正常。 第一次设置样式有效,但随后更改样式的尝试无效。 如果我复制样式并更改前景色,一切正常。 *一切正常 基本样式: <Style TargetType="HyperlinkButt

我正在尝试为超链接控件设置不同的样式。新样式基于与前一样式相同的基础样式,前一样式设置为“控件”,并且“前景”属性已覆盖为新颜色。 但在应用上前景并没有改变

几点注意: 如果覆盖属性为FontSize,则一切正常。
在Silverlight 4中,一切正常。
如果我删除BasedOn属性(不从基类派生),一切正常。
第一次设置样式有效,但随后更改样式的尝试无效。
如果我复制样式并更改前景色,一切正常。
*一切正常

基本样式:

<Style TargetType="HyperlinkButton" x:Key="NormalHyperlinkStyle">
    <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}"/>
    <Setter Property="FontSize" Value="{StaticResource DataGridFontSize}"/>
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Cursor" Value="Hand" />
    <Setter Property="Foreground" Value="{StaticResource BaseColor4}" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="Padding" Value="1"/>
    <Setter Property="VerticalContentAlignment" Value="Top" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="HyperlinkButton">
                <Grid Background="{TemplateBinding Background}" Cursor="{TemplateBinding Cursor}">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <ColorAnimation Duration="0" To="{StaticResource AccentColor}" Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="contentPresenter" />
                                    <DoubleAnimation Duration="0" To="1.0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Underline" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed" />
                            <VisualState x:Name="Disabled">
                                <Storyboard>
                                    <ColorAnimation Duration="0" To="#FFA0A0A0" Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="contentPresenter" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="FocusStates">
                            <VisualState x:Name="Focused">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Unfocused" />
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>

                    <StackPanel Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" UseLayoutRounding="True">
                        <ContentControl x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" />
                        <Rectangle x:Name="Underline" Height="1" VerticalAlignment="Bottom" Fill="{StaticResource AccentColorBrush}" Margin="0,1,0,2" Opacity="0" />
                    </StackPanel>

                    <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="False" Margin="0" Opacity="0" RadiusX="2" RadiusY="2" Stroke="{StaticResource FocusVisualBrush}" StrokeThickness="{StaticResource FocusVisualStrokeThickness}" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
<Style x:Key="ToolbarHyperlinkSelectedStyle" TargetType="HyperlinkButton" BasedOn="{StaticResource NormalHyperlinkStyle}">
    <Setter Property="Foreground" Value="{StaticResource AccentColor}" />
</Style>
        selectedButton.Style =
            (Style)Application.Current.Resources["ToolbarHyperlinkSelectedStyle"];