第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Windows Phone 7(WP7)單擊時(shí)更改按鈕的背景顏色

Windows Phone 7(WP7)單擊時(shí)更改按鈕的背景顏色

這似乎是一個(gè)非常非常簡(jiǎn)單的問(wèn)題,但我無(wú)法弄清楚。罪魁禍?zhǔn)姿坪跏荳P7的默認(rèn)樣式。單擊按鈕時(shí),它將背景顏色更改為白色,然后返回到該按鈕的默認(rèn)背景。我遇到的問(wèn)題是我想在單擊按鈕時(shí)更改按鈕的背景。我找不到任何可能的方式來(lái)做到這一點(diǎn)。我試過(guò)在代碼中設(shè)置背景,但這無(wú)濟(jì)于事。我認(rèn)為它已被默認(rèn)樣式覆蓋。我嘗試在Blend中使用“屬性更改”行為,但結(jié)果完全相同。我嘗試為按鈕創(chuàng)建一個(gè)新的視覺(jué)狀態(tài)并在單擊時(shí)進(jìn)行設(shè)置,但這有點(diǎn)小問(wèn)題,并且要處理的按鈕數(shù)量也很大。另外,它沒(méi)有用。我可以在單擊事件上設(shè)置其他按鈕的背景,而不能設(shè)置正在單擊的按鈕。這是一個(gè)令人討厭的障礙!我確定這是單行代碼的答案。:)
查看完整描述

3 回答

?
慕俠2389804

TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個(gè)贊

您需要做的是創(chuàng)建一個(gè)按鈕模板,該模板可以修改Pressed視覺(jué)狀態(tài)。


在混合中,選擇按鈕,單擊菜單項(xiàng)“對(duì)象”->“編輯模板”->“編輯副本...”,然后創(chuàng)建一個(gè)新模板。在“狀態(tài)”窗口中,在“公共狀態(tài)”視覺(jué)狀態(tài)組中選擇“已按下”視覺(jué)狀態(tài)?,F(xiàn)在,在對(duì)象層次結(jié)構(gòu)中選擇ButtonBackground,然后在“屬性”窗口中編輯背景畫筆。


我將Pressed狀態(tài)的背景編輯為純青色,最后得到了類似XAML的文字。


<phone:PhoneApplicationPage ...>

    <phone:PhoneApplicationPage.Resources>

        <Style x:Key="ButtonStyle1" TargetType="Button">

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

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">

                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/>

                                            </ObjectAnimationUsingKeyFrames>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">

                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/>

                                            </ObjectAnimationUsingKeyFrames>

                                            <ColorAnimation Duration="0" To="Cyan" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ButtonBackground" d:IsOptimized="True"/>

                                        </Storyboard>

                                    </VisualState>

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

                                        </Storyboard>

                                    </VisualState>

                                </VisualStateGroup>

                            </VisualStateManager.VisualStateGroups>

                            <Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0" Margin="{StaticResource PhoneTouchTargetOverhang}" Background="Black">

                                <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>

                            </Border>

                        </Grid>

                    </ControlTemplate>

                </Setter.Value>

            </Setter>

        </Style>

    </phone:PhoneApplicationPage.Resources>


    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Button Content="Button" Style="{StaticResource ButtonStyle1}"/>

    </Grid>

</phone:PhoneApplicationPage>



查看完整回答
反對(duì) 回復(fù) 2019-12-12
?
楊__羊羊

TA貢獻(xiàn)1943條經(jīng)驗(yàn) 獲得超7個(gè)贊

我認(rèn)為參考實(shí)際背景,然后進(jìn)行更改可能會(huì)有所幫助。這是一個(gè)將實(shí)例作為按鈕的方法。


        private void HighlightButton(Button btnToHighlight)

        {


            SolidColorBrush sBrush = (SolidColorBrush)btnToHighlight.Background;



            sBrush.Color = //enter your colour here

            btnToHighlight.Background = sBrush;


        }



查看完整回答
反對(duì) 回復(fù) 2019-12-12
?
千萬(wàn)里不及你

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊

<ControlTemplate x:Key="ButtonNextOver" TargetType="Button">

                <Grid>

                    <VisualStateManager.VisualStateGroups>

                        <VisualStateGroup x:Name="CommonStates">

                            <VisualState x:Name="Normal"/>

                            <VisualState x:Name="MouseOver">

                                <Storyboard>

                                    <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetProperty="Background" Storyboard.TargetName="hoverbutton">

                                        <DiscreteObjectKeyFrame KeyTime="00:00:00">

                                            <DiscreteObjectKeyFrame.Value>

                                                <ImageBrush ImageSource="/NhomMua;component/Image/ico_next_over.png"/>

                                            </DiscreteObjectKeyFrame.Value>

                                        </DiscreteObjectKeyFrame>

                                    </ObjectAnimationUsingKeyFrames>

                                </Storyboard>

                            </VisualState>

                        </VisualStateGroup>

                        <VisualStateGroup x:Name="FocusStates">

                            <VisualState x:Name="Focused"/>

                            <VisualState x:Name="Unfocused"/>

                        </VisualStateGroup>

                    </VisualStateManager.VisualStateGroups>

                    <Border x:Name="hoverbutton">

                        <Border.Background>

                            <ImageBrush ImageSource="/NhomMua;component/Image/ico_next.png"/>

                        </Border.Background>

                    </Border>

                </Grid>

            </ControlTemplate>



查看完整回答
反對(duì) 回復(fù) 2019-12-12
  • 3 回答
  • 0 關(guān)注
  • 526 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)