2017-12-12 72 views
1

버튼이 있고이 버튼의 정적 리소스 (CreateNewItemButtonStyle 여기)에 스타일을 설정하는 상황입니다. 또한 툴팁이 있으며이 툴팁 위에 마우스를 올리면 텍스트가 표시됩니다 ("SelectAllLines"여기). 내용 영역을 제외하고 버튼 영역 위로 마우스를 가져 가면 툴팁 텍스트가 올바르게 표시됩니다 (내용 "AL"에 마우스를 올리면 툴팁에 "AL"이 표시됨).만 표시됨 " 전체 단추 영역 툴팁에서 SelectAllLines ").버튼 설명 위로 마우스를 올리면 툴팁에 다른 텍스트가 표시됩니다.

내가 사용하고있는 스타일 때문에 알아 냈습니다.

<Style x:Key="CreateNewItemButtonStyle" TargetType="Button"> 
<Setter Property="OverridesDefaultStyle" Value="True" /> 
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" /> 
<Setter Property="BorderThickness" Value="1" /> 
<Setter Property="TextBlock.FontSize" Value="10" /> 
<Setter Property="HorizontalAlignment" Value="Center" /> 
<Setter Property="VerticalAlignment" Value="Center" /> 
<Setter Property="Cursor" Value="Hand" /> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="Button"> 
      <Border 
       Background="{TemplateBinding Background}" 
       BorderBrush="{TemplateBinding BorderBrush}" 
       BorderThickness="{TemplateBinding BorderThickness}" 
       SnapsToDevicePixels="True"> 
       <ContentPresenter 
        HorizontalAlignment="Center" 
        VerticalAlignment="Center" 
        Content="{TemplateBinding Content}" 
        TextBlock.TextAlignment="Center" /> 
      </Border> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 
<Style.Triggers> 
    <Trigger Property="IsMouseOver" Value="True"> 
     <Setter Property="Background" Value="{StaticResource ActiveButtonBrush}" /> 
     <Setter Property="BorderBrush" Value="{StaticResource ActiveBorderBrush}" /> 
    </Trigger> 
    <Trigger Property="IsPressed" Value="True"> 
     <Setter Property="Background" Value="{StaticResource ActiveButtonBrush}" /> 
     <Setter Property="BorderBrush" Value="{StaticResource ActiveBorderBrush}" /> 
    </Trigger> 
    <Trigger Property="IsEnabled" Value="False"> 
     <Setter Property="Cursor" Value="Arrow" /> 
    </Trigger> 
</Style.Triggers> 

:

하지만 내가 어떻게 여기

<Button 
    x:Name="AllLinesButtonX" 
    Background="{StaticResource FlowPowderBlackBrush}" 
    Click="AllLinesButtonX_OnClick" 
    Command="{Binding AllLinesCommand}" 
    Content="AL" 
    MouseRightButtonUp="SelectGeometryToggleButton_OnMouseRightButtonUp" 
    Style="{StaticResource CreateNewItemButtonStyle}" //If i remove this line it stops showing "AL", just shows "SelectedAllLines" which is the correct behavior 
    ToolTip="SelectAllLines" 
</Button> 

을 도구 설명 = "선택한 라인"을 수행하여 설정 한 내 전체 버튼 영역 내 툴팁에 동일한 텍스트를 가지고하는

스타일의 열쇠입니다
+0

.. –

답변