silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在silverlight中按下按钮突出显示大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_696_0@

概述

我有一个按钮,我添加一个图像作为其背景,但当我按下按钮时,我在按钮的背景上得到一个正方形(突出显示).我怎么能删除这个? <Button VerticalAlignment="Top" HorizontalAlignment="left" BorderBrush="Transparent" Click="FirstCubeSELEcted" x:Name="cube1Button" Paddi
我有一个按钮,我添加一个图像作为其背景,但当我按下按钮时,我在按钮的背景上得到一个正方形(突出显示).我怎么能删除这个?

<Button VerticalAlignment="Top" HorizontalAlignment="Left" BorderBrush="Transparent" Click="FirstCubeSELEcted" x:Name="cube1Button"   Padding="0"   Margin="1,-1,0">
                <Image x:Name="buttonImage" source="/images/cub2onbtn.png" Width="176" Height="176" />
            </Button>

我通常在表达式混合中执行此操作,但我现在无法访问它

解决方法

您需要从按钮中删除按下的视觉样式:

<Style x:Key="ButtonStyle1" TargetType="Button">
        <Setter Property="BACkground" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="{Staticresource PhoneForegroundBrush}"/>
        <Setter Property="Foreground" Value="{Staticresource PhoneForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="{Staticresource PhoneBorderThickness}"/>
        <Setter Property="FontFamily" Value="{Staticresource PhoneFontFamilySemiBolD}"/>
        <Setter Property="FontSize" Value="{Staticresource PhoneFontSizeMediumLargE}"/>
        <Setter Property="Padding" Value="10,3,10,5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid BACkground="Transparent">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouSEOver"/>
                                <VisualState x:Name="Pressed"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Staticresource PhoneDisabledBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBACkground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Staticresource PhoneDisabledBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BACkground" Storyboard.TargetName="ButtonBACkground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="ButtonBACkground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" BACkground="{TemplateBinding BACkgrounD}" CornerRadius="0" Margin="{Staticresource PhoneTouchTargetOverhang}">
                            <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplatE}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding ForegrounD}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

大佬总结

以上是大佬教程为你收集整理的在silverlight中按下按钮突出显示全部内容,希望文章能够帮你解决在silverlight中按下按钮突出显示所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。