2012-07-18 76 views
0

我在列表框上有一個按鈕。我在按鈕上應用了樣式。但是,它不會在Pressed VisualState上觸發。我相信風格是沒有問題的,因爲另一個按鈕在其他頁面上使用了這種風格。有人會告訴我如何解決這個問題。謝謝。ListBoxItem中按鈕上的按下狀態不會觸發

,以下是我的App.xaml頁面風格:

<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"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="yellow"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
            </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> 
             <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> 

以下是我control.xaml頁

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <ScrollViewer Style="{StaticResource ScrollViewerStyle1}" Background="#00E23162"> 
      <ListBox x:Name="lstCall" HorizontalAlignment="Left" Margin="6,6,0,0" VerticalAlignment="Top" Width="400" SelectionChanged="lstCall_SelectionChanged" > 
       <ListBox.ItemTemplate> 
        <DataTemplate> 
         <StackPanel Orientation="Horizontal" Height="65" Width="400"> 
          <Image Source="{Binding Type}" Width="35" Height="35"/> 
          <TextBlock Width="240" Height="65" Text="{Binding summary}" TextWrapping="Wrap" 
              Style="{StaticResource PhoneTextAccentStyle}" /> 
          <Button Width="135" Height="65" ClickMode="Press" Click="Action_Click" Style="{StaticResource ButtonStyle1}" 
              Visibility="{Binding isVisibility, Converter={StaticResource VisibilityConverter}}"> 
           <Button.Content> 

            <TextBlock Width="85" Height="65" Text="{Binding ActionCaption}" 
                 Style="{StaticResource LabelStyle_20}"  /> 

           </Button.Content> 
          </Button> 
         </StackPanel>       

        </DataTemplate> 
       </ListBox.ItemTemplate> 
      </ListBox> 
     </ScrollViewer> 
    </Grid> 

回答

0

的sytle是罰款。由於點擊事件期間顯示Meesage框,我沒有看到顏色變化。