2012-08-23 3 views
0

템플릿의 hiperlink 버튼에 대한 스타일이 많이 동일합니다.Silverlight 5의 템플릿 변경 사항과 동일한 스타일 재사용

다음은 XAML 단편

<Style x:Key="HeatmapLinkStyle" TargetType="HyperlinkButton"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="HyperlinkButton"> 
       <Grid Margin="4,2" Height="40" VerticalAlignment="Top"> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal"/> 
          <VisualState x:Name="MouseOver"> 
           <Storyboard> 
            <DoubleAnimation Duration="0:0:0.2" To="1.5" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="element" d:IsOptimized="True"/> 
            <DoubleAnimation Duration="0:0:0.2" To="1.5" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="element" d:IsOptimized="True"/> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="LinkStates"> 
          <VisualState x:Name="ActiveLink"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ActiveLinkBorder" Storyboard.TargetProperty="(UIElement.Visibility)"> 
             <DiscreteObjectKeyFrame KeyTime="00:00:00"> 
              <DiscreteObjectKeyFrame.Value> 
               <Visibility>Visible</Visibility> 
              </DiscreteObjectKeyFrame.Value> 
             </DiscreteObjectKeyFrame> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="InactiveLink"/> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <Grid Width="32" Height="32" VerticalAlignment="Top"> 
         <Path Data="M50.5,4.7500001C25.232973,4.75 4.75,25.232973 4.7500001,50.5 4.75,75.767029 25.232973,96.25 50.5,96.25 75.767029,96.25 96.25,75.767029 96.25,50.5 96.25,25.232973 75.767029,4.75 50.5,4.7500001z M50.5,0C78.390381,0 101,22.609621 101,50.5 101,78.390381 78.390381,101 50.5,101 22.609621,101 0,78.390381 0,50.5 0,22.609621 22.609621,0 50.5,0z" Stretch="Fill" Fill="#FF3FA9F5" Visibility="Visible" /> 
         <Path x:Name="element" Data="F1M-1834.73,-354.432L-1772.06,-354.432 -1772.06,-417.099 -1834.73,-417.099 -1834.73,-354.432z M-1832.68,-385.765L-1803.39,-385.765 -1803.39,-415.052 -1774.11,-415.052 -1774.11,-385.765 -1803.39,-385.765 -1803.39,-356.484 -1832.68,-356.484 -1832.68,-385.765z" Stretch="Uniform" Fill="#FF3FA9F5" Width="16" Height="16" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5"> 
          <Path.RenderTransform> 
           <CompositeTransform ScaleY="1" ScaleX="1"/> 
          </Path.RenderTransform> 
         </Path> 
         <Ellipse x:Name="container" Fill="Transparent" Cursor="Hand" Height="32" Width="32"/> 
        </Grid> 
        <Border x:Name="ActiveLinkBorder" Width="32" Height="4" VerticalAlignment="Bottom" Opacity="0.5" Background="#FF3FA9F5" Visibility="Collapsed"/> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

유일한 변경 부분 "요소"로의 데이터이다.

기본 스타일을 하나만 사용하고 다른 스타일을 변경하는 방법이 있습니까?

감사합니다.

+0

당신은 스타일 DataProperty 바인딩을 설정할 수 있습니다 도움이되기를 바랍니다 당신이 하이퍼 링크 버튼의 데이터 컨텍스트를 설정하면 그것이 잘 작동합니다 :

은 여기 좋은 예이다. – vinod8812

답변

0

기본 스타일을 생성하고 상속 할 수 있습니다. basedOn Style

그것이

+0

Vinicius에게 감사의 말을 전합니다. 단 하나의 세터가 있기 때문에이 접근법을 사용할 수 없습니다.이 템플릿은 템플릿 용입니다. 하지만 기본 스타일을 사용할 수 없도록 템플릿 안의 경로를 변경해야합니까? – user1619456

+0

나는 성공하지 못하고 마지막 시간을 보냈습니다. 죄송 해요. – Vinicius

관련 문제