2012-08-07 1 views
0

Silverlight에서 NumericUpDown 컨트롤을 사용하고 싶습니다.Silverlight NumericUpDownControl에서 SpinnerStyle이 작동하지 않습니다.

<Style x:Key="NoSpinner" TargetType="toolkit:Spinner"> 
    <Setter Property="Visibility" Value="Collapsed" /> 
</Style> 

제어 :

<toolkit:NumericUpDown SpinnerStyle="{StaticResource NoSpinner}" /> 

하지만 회는 여전히 보여줍니다! 나는이 컨트롤의 저자가하는 방식으로 이것을하고있다 suggests (link).

리소스가 발견되었습니다. 오류가 없으며 동일한 영역에 정의 된 다른 스타일을 적용 할 수 있습니다.

+0

컨트롤을 지나서 컨트롤/탭의 내용을 편집하는 데 걸리는 탭 수를 줄이기 위해이 작업을 시도했습니다. 내 대답은 텍스트 상자를 유일한 탭 수 있도록 컨트롤을 다시 템플릿. – Ethan

답변

0

블렌드가 없었기 때문에 표준 템플릿이 무엇인지에 대한 액세스 권한이없는 경우 이러한 컨트롤 템플릿을 편집하는 것이 매우 어렵습니다. 이에 대한 해결책은 블렌드의 미리보기 복사본을 얻는 것과 컨트롤을 다시 템플릿 화하는 것입니다.

<Style TargetType="toolkit:NumericUpDown" x:Key="InputNumericUpDown"> 
    <Setter Property="Width" Value="111" /> 
    <Setter Property="Height" Value="23" /> 
    <Setter Property="IsTabStop" Value="False" /> 
    <Setter Property="HorizontalAlignment" Value="Left" /> 
    <Setter Property="Margin" Value="5,0,0,5"/>  
    <Setter Property="Template"><!-- This template was generated in Blend --> 
     <Setter.Value> 
      <ControlTemplate TargetType="toolkit:NumericUpDown"> 
       <Grid> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualStateGroup.Transitions> 
           <VisualTransition GeneratedDuration="0"/> 
          </VisualStateGroup.Transitions> 
          <VisualState x:Name="Normal"/> 
          <VisualState x:Name="Disabled"> 
           <Storyboard> 
            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DisabledVisualElement"/> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="FocusStates"> 
          <VisualState x:Name="Focused"> 
           <Storyboard> 
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"> 
             <SplineDoubleKeyFrame KeyTime="0" Value="1"/> 
            </DoubleAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Unfocused"/> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <toolkit:ButtonSpinner x:Name="Spinner" HorizontalContentAlignment="Stretch" MinWidth="35" VerticalContentAlignment="Stretch" IsTabStop="False"> 
         <TextBox x:Name="Text" AcceptsReturn="False" BorderThickness="0" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" MinWidth="20" TextAlignment="Right" TextWrapping="NoWrap" Text="{TemplateBinding Value}" IsTabStop="True"> 
          <TextBox.Style> 
           <Style TargetType="TextBox"> 
            <Setter Property="Template"> 
             <Setter.Value> 
              <ControlTemplate TargetType="TextBox"> 
               <ScrollViewer x:Name="ContentElement" BorderThickness="0" Padding="0"/> 
              </ControlTemplate> 
             </Setter.Value> 
            </Setter> 
           </Style> 
          </TextBox.Style> 
         </TextBox> 
        </toolkit:ButtonSpinner> 
        <Border x:Name="DisabledVisualElement" Background="#A5FFFFFF" CornerRadius="2.5,2.5,2.5,2.5" IsHitTestVisible="false" Opacity="0"/> 
        <Border x:Name="FocusVisualElement" BorderBrush="#FF45D6FA" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1,1,1,1" IsHitTestVisible="False" Opacity="0"/> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

템플릿 부분은 조화에서 온 유일한 부분이지만, 그 스타일은 내가 나가 한 번 한 번 탭 컨트롤에 구할 수있는 곳으로 만들기 위해 NumericUpDowns을 위해 사용하고있는 무슨이다.

관련 문제