2012-03-23 34 views
0

有我生成按鈕細節的代碼。我想在鼠標懸停期間將broderbrush更改爲YellowGreen,但似乎沒有影響。有人會告訴我代碼有什麼問題嗎?預先感謝。有我的代碼。用於MouseOver的Viusal狀態在WindowsPhone上不起作用

<Style x:Key="CustomButtonStyle" TargetType="Button"> 
     <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate> 
        <Grid> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal"> 
            <Storyboard> 
             <DoubleAnimation To="1" Duration="0:00:00.5" Storyboard.TargetName="NormalBackground" Storyboard.TargetProperty="Opacity"/> 
             <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity"/> 
             <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="PressedBackground" Storyboard.TargetProperty="Opacity"/> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="MouseOver"> 
            <Storyboard> 
             <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="NormalBackground" Storyboard.TargetProperty="Opacity"/> 
             <DoubleAnimation To="1" Duration="0:00:00.5" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity"/> 
             <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="PressedBackground" Storyboard.TargetProperty="Opacity"/> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Pressed"> 
            <Storyboard> 
             <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="NormalBackground" Storyboard.TargetProperty="Opacity"/> 
             <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity"/> 
             <DoubleAnimation To="1" Duration="0:00:00.5" Storyboard.TargetName="PressedBackground" Storyboard.TargetProperty="Opacity"/> 
            </Storyboard> 
           </VisualState> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 

         <Border Name="NormalBackground" CornerRadius="3" BorderBrush="Black" BorderThickness="1" Background="black" /> 
         <Border Name="HoverBackground" Opacity="0" CornerRadius="3" BorderBrush="GreenYellow" BorderThickness="3" Background="Gray" /> 
         <Border Name="PressedBackground" Opacity="0" CornerRadius="8" BorderBrush="Black" BorderThickness="1" Background="Red" /> 

         <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" /> 
        </Grid> 

       </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

以下代碼顯示如何在MainPage.xaml上添加按鈕。

<Button x:Name="btnCall" Click="btnCall_Click" Grid.Row="0" Grid.Column="1" Content="test" 
Style="{StaticResource CustomButtonStyle}" /> 

回答

4

Windows Phone並沒有真正將鼠標移過。

請記住,在手機上,您沒有鼠標。你試圖做什麼(換句話說,你試圖模仿手機上的鼠標相當於什麼?)

[通常人們通過使用鼠標與模擬器進行交互,但當然有在手機本身並不相同,所以支持它並沒有太大的意義]

0

鼠標在未定義的區域移動光標,因此它需要在地板上保持接地狀態以便跟蹤根據創建的水平或垂直三角洲增加或減少位置。

觸摸屏一般設計用於在已定義的區域中選擇和選擇位置。你不會用走路鼠標「尋找」一個位置,你已經「知道」它。當你在屏幕上移動手指時,它會根據增量觸發手勢事件,而不是基於此增量移動光標。