喷丝头样式不适用于Silverlight NumericUpDownControl
我在Silverlight中有一个NumericUpDown控件,我不想使用微调器喷丝头样式不适用于Silverlight NumericUpDownControl,silverlight,silverlight-toolkit,Silverlight,Silverlight Toolkit,我在Silverlight中有一个NumericUpDown控件,我不想使用微调器 <Style x:Key="NoSpinner" TargetType="toolkit:Spinner"> <Setter Property="Visibility" Value="Collapsed" /> </Style> 控件: <toolkit:NumericUpDown SpinnerStyle="{StaticResource NoSpinne
<Style x:Key="NoSpinner" TargetType="toolkit:Spinner">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
控件:
<toolkit:NumericUpDown SpinnerStyle="{StaticResource NoSpinner}" />
但旋转器仍然显示!我是用这个控件的作者的方式来做的
我知道资源正在被找到。没有给出错误,并且我能够应用在同一区域中定义的其他样式。我没有Blend,这使得如果您无法访问标准模板,则编辑这些控件的模板非常困难。解决方案是获取blend的预览副本,并使用它重新设置控件的模板
<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>
模板部分是唯一来自blend的部分,但这种样式正是我在NumericUpdown中使用的,它可以使您的选项卡一次到达控件,一次离开控件。我这样做是为了减少通过控件编辑控件/选项卡内容所需的选项卡数量。我的答案是重新设置控件模板,使文本框成为唯一的制表符。