2015-11-11 3 views
1

У меня есть кнопка с фоновым изображением и белым текстом. Когда я нажимаю на нее или нажимаю мышь (фокус), вы видите черную рамку, а текст остается черным. Что я могу сделать, чтобы игнорировать мышь и принимать визуальный эффект щелчка при нажатии?Удалить фокус с кнопки на Windows 10 Core - XAML

Уже добавьте это, но никакого эффекта.

<Style x:Key="ButtonActionStyle" TargetType="Button"> 
    ... 
    <Setter Property="UseLayoutRounding" Value="False"/> 
    <Setter Property="UseSystemFocusVisuals" Value="False"/> 
</Style> 

Спасибо


Этот код делать то, что мне нужно, но не клик визуальный эффект: х

<Style x:Key="ButtonActionStyle" TargetType="Button"> 
    ... 
    <Setter Property="UseLayoutRounding" Value="False"/> 
    <Setter Property="UseSystemFocusVisuals" Value="False"/> 

    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate> 
       <Grid> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal"/> 
          <VisualState x:Name="Pressed"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="grid"> 
             <DiscreteObjectKeyFrame KeyTime="1"> 
              <DiscreteObjectKeyFrame.Value> 
               <x:Int32>1</x:Int32> 
              </DiscreteObjectKeyFrame.Value> 
             </DiscreteObjectKeyFrame> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="PointerOver"/> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <Grid> 
         <Grid x:Name="grid" Margin="0" Grid.Row="0" Grid.RowSpan="1"> 
          <Border 
           BorderBrush="{TemplateBinding Background}" 
           BorderThickness="0" 
           CornerRadius="0" 
           Background="{TemplateBinding Background}"/> 
          <ContentPresenter> 
           <TextBlock 
            FontFamily="{TemplateBinding FontFamily}" 
            SelectionHighlightColor="{TemplateBinding Foreground}" 
            FontSize="{TemplateBinding FontSize}" 
            Foreground="{TemplateBinding Foreground}" 
            HorizontalAlignment="Center" 
            VerticalAlignment="Center" 
            Height="Auto" 
            Width="Auto" 
            Text="{Binding Content, RelativeSource={RelativeSource Mode=TemplatedParent}}"/> 
          </ContentPresenter> 
         </Grid> 
        </Grid> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

ответ

0

this на основе учебника, это не сделано.

<Style x:Key="ButtonActionStyle" TargetType="Button"> 
    ... 
    <Setter Property="UseLayoutRounding" Value="False"/> 
    <Setter Property="UseSystemFocusVisuals" Value="False"/> 

    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate> 
       <Grid> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal"/> 
          <VisualState x:Name="PointerOver"/> 
          <VisualState x:Name="Pressed"> 
           <VisualState.Setters> 
            <Setter Target="grid.(Grid.Row)" Value="0"/> 
            <Setter Target="grid.(Canvas.ZIndex)" Value="0"/> 
            <Setter Target="grid.(UIElement.RenderTransformOrigin)"> 
             <Setter.Value> 
              <Foundation:Point>0.5,0.5</Foundation:Point> 
             </Setter.Value> 
            </Setter> 
            <Setter Target="grid.(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Value="1"/> 
            <Setter Target="grid.(UIElement.Projection).(PlaneProjection.LocalOffsetX)" Value="5"/> 
            <Setter Target="grid.(UIElement.Projection).(PlaneProjection.LocalOffsetY)" Value="5"/> 
            <Setter Target="grid.(UIElement.Projection).(PlaneProjection.LocalOffsetZ)" Value="0"/> 
           </VisualState.Setters> 
          </VisualState> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <Grid> 
         <Grid x:Name="grid" Margin="0" Grid.Row="0" Grid.RowSpan="1"> 
          <Grid.Projection> 
           <PlaneProjection/> 
          </Grid.Projection> 
          <Grid.RenderTransform> 
           <CompositeTransform/> 
          </Grid.RenderTransform> 
          <Border 
           BorderBrush="{TemplateBinding Background}" 
           BorderThickness="0" 
           CornerRadius="0" 
           Background="{TemplateBinding Background}"/> 
          <ContentPresenter> 
           <TextBlock 
            FontFamily="{TemplateBinding FontFamily}" 
            SelectionHighlightColor="{TemplateBinding Foreground}" 
            FontSize="{TemplateBinding FontSize}" 
            Foreground="{TemplateBinding Foreground}" 
            HorizontalAlignment="Center" 
            VerticalAlignment="Center" 
            Height="Auto" 
            Width="Auto" 
            Text="{Binding Content, RelativeSource={RelativeSource Mode=TemplatedParent}}"/> 
          </ContentPresenter> 
         </Grid> 
        </Grid> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style>