首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

在Silverlight中单击HyperlinkBut​​ton时,如何避免出现蓝色边框?

在Silverlight中,要避免在单击HyperlinkButton时出现蓝色边框,可以通过设置HyperlinkButton的样式来实现。以下是一个简单的示例:

  1. 在您的Silverlight项目中,打开App.xaml文件。
  2. 在App.xaml文件中,添加以下样式:
代码语言:xml<Style x:Key="NoBorderHyperlinkButton" TargetType="HyperlinkButton">
复制
   <Setter Property="Template">
       <Setter.Value>
           <ControlTemplate TargetType="HyperlinkButton">
                <Grid>
                   <VisualStateManager.VisualStateGroups>
                       <VisualStateGroup x:Name="CommonStates">
                           <VisualState x:Name="Normal" />
                           <VisualState x:Name="MouseOver" />
                           <VisualState x:Name="Pressed">
                               <Storyboard>
                                   <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="TextBlock">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                           <VisualState x:Name="Disabled">
                               <Storyboard>
                                   <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="TextBlock">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}" />
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <TextBlock x:Name="TextBlock" Text="{TemplateBinding Content}" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
  1. 在您的Silverlight页面中,将新创建的样式应用于HyperlinkButton:
代码语言:xml
复制
<HyperlinkButton Content="点击这里" Style="{StaticResource NoBorderHyperlinkButton}" />

现在,当您单击HyperlinkButton时,不会出现蓝色边框。这个方法适用于Silverlight应用程序,并且不需要使用第三方库或框架。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

领券