2012-05-08 4 views
0

StandardStyles.xamlで作成されたBackButtonStyleを使用しました(新しいメトロプロジェクトを作成中)。BackButtonStyle(メトロアプリケーションのStandardStyles.xamlの一部)は他の要素を無効にします

問題は、他のコントロールを無効にすることです。ボタン、およびスライダは無効になっており、呼び出すことはできません。

BackButtonStyleを削除すると、他のボタン/スライダが正常に機能します。

 <Grid Grid.Row="0"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto"/> 
      <ColumnDefinition Width="*"/> 
     </Grid.ColumnDefinitions> 
     <!--Style="{StaticResource BackButtonStyle}"--> 
     <Button x:Name="backButton" Click="GoBack" Style="{StaticResource BackButtonStyle}" Margin="10" >Back</Button> 
     <TextBlock Grid.Column="1" Text="Application settings" Foreground="White" FontSize="24" HorizontalAlignment="Center" Margin="10"/> 
     </Grid> 
     <StackPanel Grid.Row="1"> 

     <TextBlock Grid.Row="1" FontSize="14" Text="Toast Notification Interval (minutes) " Margin="10"/> 
     <Slider Grid.Row="2" x:Name="NotificationIntervalSlider" Minimum="1" Maximum="10"/> 
     <TextBlock Grid.Row="3" FontSize="14" x:Name="lblIntervalInfo" Margin="10"/> 
     <Button Grid.Row="4">Text</Button> 

BackButtonStyleは

 <Style x:Key="BackButtonStyle" TargetType="Button"> 
    <Setter Property="MinWidth" Value="0"/> 
    <Setter Property="Width" Value="48"/> 
    <Setter Property="Height" Value="48"/> 
    <Setter Property="Margin" Value="36,0,36,36"/> 
    <Setter Property="VerticalAlignment" Value="Bottom"/> 
    <Setter Property="FontFamily" Value="Segoe UI Symbol"/> 
    <Setter Property="FontWeight" Value="Normal"/> 
    <Setter Property="FontSize" Value="56"/> 
    <Setter Property="AutomationProperties.AutomationId" Value="BackButton"/> 
    <Setter Property="AutomationProperties.Name" Value="Back"/> 
    <Setter Property="AutomationProperties.ItemType" Value="Navigation Button"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="Button"> 
       <Grid x:Name="RootGrid"> 
        <Grid Margin="-1,-16,0,0"> 
         <TextBlock x:Name="BackgroundGlyph" Text="&#xE0A8;" Foreground="{StaticResource BackButtonBackgroundBrush}"/> 
         <TextBlock x:Name="NormalGlyph" Text="{StaticResource BackButtonGlyph}" Foreground="{StaticResource BackButtonGlyphBrush}"/> 
         <TextBlock x:Name="ArrowGlyph" Text="&#xE0A6;" Foreground="{StaticResource BackButtonPressedGlyphBrush}" Opacity="0"/> 
        </Grid> 
        <Rectangle 
         x:Name="FocusVisualWhite" 
         IsHitTestVisible="False" 
         Stroke="{StaticResource FocusVisualWhiteStrokeBrush}" 
         StrokeEndLineCap="Square" 
         StrokeDashArray="1,1" 
         Opacity="0" 
         StrokeDashOffset="1.5"/> 
        <Rectangle 
         x:Name="FocusVisualBlack" 
         IsHitTestVisible="False" 
         Stroke="{StaticResource FocusVisualBlackStrokeBrush}" 
         StrokeEndLineCap="Square" 
         StrokeDashArray="1,1" 
         Opacity="0" 
         StrokeDashOffset="0.5"/> 

        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal" /> 
          <VisualState x:Name="PointerOver"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonHoverBackgroundBrush}"/> 
            </ObjectAnimationUsingKeyFrames> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NormalGlyph" Storyboard.TargetProperty="Foreground"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonHoverGlyphBrush}"/> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Pressed"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonGlyphBrush}"/> 
            </ObjectAnimationUsingKeyFrames> 
            <DoubleAnimation 
             Storyboard.TargetName="ArrowGlyph" 
             Storyboard.TargetProperty="Opacity" 
             To="1" 
             Duration="0"/> 
            <DoubleAnimation 
             Storyboard.TargetName="NormalGlyph" 
             Storyboard.TargetProperty="Opacity" 
             To="0" 
             Duration="0"/> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Disabled"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Visibility"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="FocusStates"> 
          <VisualState x:Name="Focused"> 
           <Storyboard> 
            <DoubleAnimation 
             Storyboard.TargetName="FocusVisualWhite" 
             Storyboard.TargetProperty="Opacity" 
             To="1" 
             Duration="0"/> 
            <DoubleAnimation 
             Storyboard.TargetName="FocusVisualBlack" 
             Storyboard.TargetProperty="Opacity" 
             To="1" 
             Duration="0"/> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Unfocused" /> 
          <VisualState x:Name="PointerFocused" /> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
    </Style> 

私は私が手動で削除したいくつかのIsHitTestVisible=falseを見ることができ(それはデフォルトで提供される、大きい)以下でありますテストされ、同じresウルトラ。

+0

は、設定の魅力に、このようにするために?それがすべて入っているグリッドの定義は何ですか? 2つの行定義を持っていますか? –

+0

はい、それは設定の魅力にあるとシミュレートされます。 私はhttp://devlicio.us/blogs/derik_whittaker/archive/2011/09/28/lighting-up-your-c-metro-apps-by-using-the-settings-contract.aspxに従った。私の理解によると、UIはメインアプリケーションの一部であり、設定チャームのイベントで表示/非表示(マージンを操作することによって)されます。 したがって、設定の一部が魅力的であるように見えますが、実際はそうではありません。 – Tilak

答えて

1

あなたはここに証拠金とコンテンツを取り払う試すことができます。

<Button x:Name="backButton" Click="GoBack" Style="{StaticResource BackButtonStyle}" Margin="10" >Back</Button> 

それ

<Button 
    Click="GoBack" 
    Style="{StaticResource BackButtonStyle}" /> 
+0

これは、簡潔にするために行うことができます。しかし、元の質問とは無関係です。 – Tilak

関連する問題