2011-05-03 3 views
2

저는 다양한 상태가 될 수있는 실버 라이트의 버튼 컨트롤을 만들고 있습니다. 각 상태는 자체 모양, 다른 색상 및 버튼의 다른 이미지를 가지고 있습니다.codebehind에서 silverlight 컨트롤의 시각적 요소를 설정 하시겠습니까?

코드 비하인드에서 컨트롤의 시각적 속성을 어떻게 수정할 수 있는지 궁금합니다.

다음은 XAML의 :

<Style x:Key="MyButton" TargetType="Button"> 
      <Setter Property="FontSize" Value="10"/> 
      <Setter Property="Height" Value="22"/> 
      <Setter Property="Foreground" Value="White"/> 
      <Setter Property="VerticalAlignment" Value="Center"/> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="Button"> 
         <Grid Name="RootElement"> 
          <vsm:VisualStateManager.VisualStateGroups> 
           <vsm:VisualStateGroup x:Name="CommonStates"> 
            <vsm:VisualState x:Name="Normal"/> 
            <vsm:VisualState x:Name="MouseOver"> 
            </vsm:VisualState> 
            <vsm:VisualState x:Name="Pressed"> 
             <Storyboard> 
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:01.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.RenderTransform). (TransformGroup.Children)[0].(ScaleTransform.ScaleX)"> 
               <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.94"/> 
              </DoubleAnimationUsingKeyFrames> 
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:01.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.RenderTransform). (TransformGroup.Children)[0].(ScaleTransform.ScaleY)"> 
               <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.94"/> 
              </DoubleAnimationUsingKeyFrames> 
             </Storyboard> 
            </vsm:VisualState> 
            <vsm:VisualState x:Name="Disabled"> 
             <Storyboard/> 
            </vsm:VisualState> 
           </vsm:VisualStateGroup> 
           <vsm:VisualStateGroup x:Name="FocusStates"> 
            <vsm:VisualState x:Name="Focused"> 
             <Storyboard/> 
            </vsm:VisualState> 
            <vsm:VisualState x:Name="Unfocused"/> 
           </vsm:VisualStateGroup> 
          </vsm:VisualStateManager.VisualStateGroups> 
          <Border CornerRadius="1,1,1,1" Background="{StaticResource BlueVerticalGradientBrush}" BorderBrush="Red" BorderThickness="1,1,1,1" x:Name="MouseOver" RenderTransformOrigin="0.5,0.5"> 
           <Border.RenderTransform> 
            <TransformGroup> 
             <ScaleTransform/> 
             <SkewTransform/> 
             <RotateTransform/> 
             <TranslateTransform/> 
            </TransformGroup> 
           </Border.RenderTransform> 
           <ContentPresenter x:Name="contentPresenter" Margin="10,0,10,0" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="Center" HorizontalAlignment="Center"/> 
          </Border> 
         </Grid> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
      <Setter Property="MinWidth" Value="65"/> 
     </Style> 
+0

버튼에 대한 xaml을 게시 할 수 있습니까? –

+0

방금 ​​xaml을 게시했습니다 – tweetypi

+0

코드를 수정하여 컨트롤에 할당 된 스타일을 수정하거나 스타일을 변경 하시겠습니까? –

답변

2

요소에 x : Name을주고 속성에 코드 이름으로 액세스하려고 했습니까?

관련 문제