如何重新设置XamNumericGrid上/下按钮?

时间:2012-05-29 22:53:55

标签: wpf styles infragistics

在Infragistics NetAdvantage中,如何重新设置XamNumericEditor上/下按钮?

我查看了DefaultStyles,这很难跟进。

  1. XamNumericEditor样式为空;它只是XamMaskedEditor的别名。
  2. 但是,
  3. XamMaskedEditor似乎没有在其中定义任何向上/向下按钮。这有什么作用?
  4. 如果我能找到一个非常复杂的实例,那真的很棒。

    感谢任何可以提供帮助的人。

1 个答案:

答案 0 :(得分:2)

以下是DefaultStyle EditorsGeneric.xaml的片段:

<Grid x:Name="PART_SpinButtons" DockPanel.Dock="Right" Visibility="{TemplateBinding SpinButtonVisibilityResolved}" Margin="0,1">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="1"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <!-- AS 2/25/11 TFS67071 -->
    <RepeatButton x:Name="spinUp" Style="{TemplateBinding SpinButtonStyle}" Focusable="false" ContentTemplate="{DynamicResource {x:Static igEditors:EditorsBrushKeys.IncreaseGlyphKey}}"/>
    <RepeatButton x:Name="spinDown" Style="{TemplateBinding SpinButtonStyle}" Focusable="false" Grid.Row="2" ContentTemplate="{DynamicResource {x:Static igEditors:EditorsBrushKeys.DecreaseGlyphKey}}"/>
</Grid>

如您所见,您可以设置SpinButtonStyle以更改应用程序中spinButton的外观。如果您也想更改内容(按钮中的向上/向下箭头),您可以覆盖EditorBrushKeys资源。

以下是有关如何更改样式的示例:

<Grid>
  <Grid.Resources>
    <!-- Change Content of the Repeat Buttons -->
    <DataTemplate x:Key="{x:Static igEditors:EditorsBrushKeys.IncreaseGlyphKey}">
      <Path
        Width="7"
        Height="4"
        Data="M 0 4 L 8 4 L 4 0 Z"
        Fill="{DynamicResource {x:Static igEditors:EditorsBrushKeys.DropdownBtnGlyphNormalForegroundFillKey}}"/>
    </DataTemplate>

    <DataTemplate x:Key="{x:Static igEditors:EditorsBrushKeys.DecreaseGlyphKey}">
      <Path
        Width="7"
        Height="4"
        Data="M 0 0 L 4 4 L 8 0 Z"
        Fill="{DynamicResource {x:Static igEditors:EditorsBrushKeys.DropdownBtnGlyphNormalForegroundFillKey}}"/>
    </DataTemplate>

    <!-- Change properties on the button -->
    <Style x:Key="mySpinButtonStyle" TargetType="{x:Type RepeatButton}">
      <Setter Property="Background" Value="Green"/>
    </Style>
  </Grid.Resources>

  <igEditors:XamNumericEditor SpinButtonDisplayMode="Always" x:Name="myEditor" Value="10" Width="120" Height="40" SpinButtonStyle="{StaticResource mySpinButtonStyle}"/>
</Grid>