2011-11-23 4 views
0

저는 Up Down 컨트롤을 사용하고 있지만 정상적으로 작동하지만 오늘은 컨트롤의 반복 버튼으로 이상한 문제를 발견했습니다. 일단 +/- 반복 버튼을 클릭하면 파란색 테두리로 강조 표시됩니다 (문제가 없지만). 문제는 페이지의 다른 버튼이나 컨트롤을 클릭해도 강조 표시된다는 것입니다. 여기 RepeatButtons가 포커스를 잃지 않고 영원히 강조 표시되지 않았습니다.

는 스크린 샷입니다 -

enter image description here

여기 내가 사용하고있는 XAML입니다 -

<!-- RepeatButton styles --> 

<Style 
    x:Key="RepeatButtonPathStyle" 
    TargetType="Path"> 
    <Setter 
     Property="Width" 
     Value="3" /> 
    <Setter 
     Property="Height" 
     Value="3" /> 
    <Setter 
     Property="MinWidth" 
     Value="3" /> 
    <Setter 
     Property="MinHeight" 
     Value="3" /> 
    <Setter 
     Property="HorizontalAlignment" 
     Value="Center" /> 
    <Setter 
     Property="VerticalAlignment" 
     Value="Center" /> 
    <Setter 
     Property="Stretch" 
     Value="None" /> 
    <Setter 
     Property="StrokeThickness" 
     Value="1" /> 
    <Setter 
     Property="Stroke" 
     Value="{Binding RelativeSource={RelativeSource AncestorType=RepeatButton}, 
Path=Foreground}" /> 
</Style> 

<DataTemplate 
    x:Key="IncreaseGlyph"> 
    <Path 
     Data="M0,1.5 H3 M1.5,0 V3" 
     Style="{StaticResource RepeatButtonPathStyle}" /> 
</DataTemplate> 

<DataTemplate 
    x:Key="DecreaseGlyph"> 
    <Path 
     Data="M0,1.5 H3" 
     Style="{StaticResource RepeatButtonPathStyle}" /> 
</DataTemplate> 

<Grid 
    Grid.Column="1"> 
    <Grid.RowDefinitions> 
     <RowDefinition 
      Height="*" /> 
     <RowDefinition 
      Height="*" /> 
    </Grid.RowDefinitions> 
    <Button 
     Grid.Row="0" 
     Grid.RowSpan="2" 
     IsHitTestVisible="True" 
     IsTabStop="False"> 
     <Button.Template> 
      <ControlTemplate 
       TargetType="Button"> 
       <Grid 
        Background="Transparent" /> 
      </ControlTemplate> 
     </Button.Template> 
    </Button> 
    <RepeatButton 
     Grid.Row="0" 
     HorizontalContentAlignment="Center" 
     Command="{Binding RelativeSource={RelativeSource TemplatedParent}, 
      Path=IncreaseCommand}" 
     ContentTemplate="{StaticResource IncreaseGlyph}" 
     ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, 
      Path=IncreaseButtonToolTip}" 
     ToolTipService.BetweenShowDelay="1000" 
     ToolTipService.InitialShowDelay="1000" 
     ToolTipService.IsEnabled="{Binding RelativeSource={RelativeSource TemplatedParent}, 
      Path=ShowUpDownButtonToolTip}"> 
    </RepeatButton> 
    <RepeatButton 
     Grid.Row="1" 
     HorizontalContentAlignment="Center" 
     Command="{Binding RelativeSource={RelativeSource TemplatedParent}, 
      Path=DecreaseCommand}" 
     ContentTemplate="{StaticResource DecreaseGlyph}" 
     ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, 
      Path=DecreaseButtonToolTip}" 
     ToolTipService.BetweenShowDelay="1000" 
     ToolTipService.InitialShowDelay="1000" 
     ToolTipService.IsEnabled="{Binding RelativeSource={RelativeSource TemplatedParent}, 
      Path=ShowUpDownButtonToolTip}"> 
    </RepeatButton> 
</Grid> 

모든 포인터는? (

<Style.Triggers> 
    <Trigger Property="IsMouseOver" Value="true"> 
    <Setter Property="Stroke" 
      Value="{Binding RelativeSource={RelativeSource AncestorType=RepeatButton}, 
         Path=Foreground}" /> 
    </Trigger> 
</Style.Triggers> 

트리거 조건이 거짓 인 경우는 다시 디폴트 값으로 스트로크를 설정합니다이 방법 : 대신 트리거

<Setter Property="Stroke" Value="{Binding RelativeSource= 
{RelativeSource AncestorType=RepeatButton},Path=Foreground}" /> 

:

답변

0

이 문제를 해결하기위한 해결책은 RepeatButton에 Focusable="False"을 설정하는 것입니다.

0

난 당신이 세터를 교체해야한다고 생각 마우스가이 경우에 있음).

+0

감사합니다. chaosmaker하지만 문제가 해결되지는 않습니다. 스트로크는 +/- 버튼의 색상을 설정하기위한 것으로 초점 문제와 관련이 없다고 생각합니다. – akjoshi

관련 문제