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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

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

3 回答

?
慕標琳琳

TA貢獻1830條經(jīng)驗 獲得超9個贊

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


在混合中,選擇按鈕,單擊菜單項“對象”->“編輯模板”->“編輯副本...”,然后創(chuàng)建一個新模板。在“狀態(tài)”窗口中,在“公共狀態(tài)”視覺狀態(tài)組中選擇“已按下”視覺狀態(tài)。現(xiàn)在,在對象層次結構中選擇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>


查看完整回答
反對 回復 2019-10-28
?
三國紛爭

TA貢獻1804條經(jīng)驗 獲得超7個贊

我認為參考實際背景,然后進行更改可能會有所幫助。這是一個將實例作為按鈕的方法。


        private void HighlightButton(Button btnToHighlight)

        {


            SolidColorBrush sBrush = (SolidColorBrush)btnToHighlight.Background;



            sBrush.Color = //enter your colour here

            btnToHighlight.Background = sBrush;


        }


查看完整回答
反對 回復 2019-10-28
?
慕尼黑8549860

TA貢獻1818條經(jīng)驗 獲得超11個贊

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


查看完整回答
反對 回復 2019-10-28
  • 3 回答
  • 0 關注
  • 534 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號