MenuScrollingVisibilityConverter MenuScrollingVisibilityConverter MenuScrollingVisibilityConverter MenuScrollingVisibilityConverter Class

Definición

Representa un convertidor de enlaces de datos para administrar la visibilidad de los botones repetidos en los menús de desplazamiento.Represents a data-binding converter to handle the visibility of repeat buttons in scrolling menus.

public ref class MenuScrollingVisibilityConverter sealed : System::Windows::Data::IMultiValueConverter
public sealed class MenuScrollingVisibilityConverter : System.Windows.Data.IMultiValueConverter
type MenuScrollingVisibilityConverter = class
    interface IMultiValueConverter
Public NotInheritable Class MenuScrollingVisibilityConverter
Implements IMultiValueConverter
Herencia
MenuScrollingVisibilityConverterMenuScrollingVisibilityConverterMenuScrollingVisibilityConverterMenuScrollingVisibilityConverter
Implementaciones

Ejemplos

En el ejemplo siguiente se usa el MenuScrollingVisibilityConverter en el ControlTemplate de un ScrollViewer para un menú.The following example uses the MenuScrollingVisibilityConverter in the ControlTemplate of a ScrollViewer for a menu. Para obtener un ejemplo completo, vea aplicación de estilos con el ejemplo ControlTemplates.For the complete example, see Styling with ControlTemplates Sample.

<!--ScrollViewer for a MenuItem-->
<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />

<Style x:Key="MenuScrollViewer"
       TargetType="{x:Type ScrollViewer}"
       BasedOn="{x:Null}">
  <Setter Property="HorizontalScrollBarVisibility"
          Value="Hidden" />
  <Setter Property="VerticalScrollBarVisibility"
          Value="Auto" />
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type ScrollViewer}">
        <Grid SnapsToDevicePixels="True">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
          </Grid.RowDefinitions>
          <Border Grid.Row="1"
                  Grid.Column="0">
            <ScrollContentPresenter Margin="{TemplateBinding Padding}" />
          </Border>
          <RepeatButton Style="{StaticResource MenuScrollButton}"
                        Grid.Row="0"
                        Grid.Column="0"
                        Command="{x:Static ScrollBar.LineUpCommand}"
                        CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                        Focusable="False">
            <RepeatButton.Visibility>
              <MultiBinding FallbackValue="Visibility.Collapsed"
                            Converter="{StaticResource MenuScrollingVisibilityConverter}"
                            ConverterParameter="0">
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="ComputedVerticalScrollBarVisibility" />
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="VerticalOffset" />
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="ExtentHeight" />
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="ViewportHeight" />
              </MultiBinding>
            </RepeatButton.Visibility>
            <Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"
                  Data="{StaticResource UpArrow}" />
          </RepeatButton>
          <RepeatButton Style="{StaticResource MenuScrollButton}"
                        Grid.Row="2"
                        Grid.Column="0"
                        Command="{x:Static ScrollBar.LineDownCommand}"
                        CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                        Focusable="False">
            <RepeatButton.Visibility>
              <MultiBinding FallbackValue="Visibility.Collapsed"
                            Converter="{StaticResource MenuScrollingVisibilityConverter}"
                            ConverterParameter="100">
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="ComputedVerticalScrollBarVisibility" />
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="VerticalOffset" />
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="ExtentHeight" />
                <Binding RelativeSource="{RelativeSource TemplatedParent}"
                         Path="ViewportHeight" />
              </MultiBinding>
            </RepeatButton.Visibility>
            <Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"
                  Data="{StaticResource DownArrow}" />
          </RepeatButton>
        </Grid>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

Comentarios

El MenuScrollingVisibilityConverter determina si un menú debe mostrar los botones de repetición cuando un menú tiene demasiados elementos para que quepa en la pantalla a la vez.The MenuScrollingVisibilityConverter determines whether a menu should display the repeat buttons when a menu has too many items to fit on the screen at once. Utilizar el convertidor con un MultiBinding que tiene cuatro enlaces.Use the converter with a MultiBinding that has four bindings. Deben ser los cuatro enlaces a las propiedades del elemento primario ScrollViewer: si los elementos de menú se organizan verticalmente (que es el valor predeterminado para los menús), enlazar a ComputedVerticalScrollBarVisibility, VerticalOffset, ExtentHeight, y ViewportHeight.The four bindings should be to properties of the parent ScrollViewer: If the menu items are organized vertically (which is the default for menus), bind to ComputedVerticalScrollBarVisibility, VerticalOffset, ExtentHeight, and ViewportHeight. Si los elementos de menú se organizan horizontalmente, enlazar a ComputedHorizontalScrollBarVisibility, HorizontalOffset, ExtentWidth, y ViewportWidth.If the menu items are organized horizontally, bind to ComputedHorizontalScrollBarVisibility, HorizontalOffset, ExtentWidth, and ViewportWidth.

Establecer MultiBinding.ConverterParameter en 0 o 100.Set MultiBinding.ConverterParameter to 0 or 100. El valor se trata como un porcentaje y determina si se oculta un botón cuando el ScrollViewer está en la ubicación especificada.The value is treated as a percentage and determines whether a button is hidden when the ScrollViewer is at the given location. Cuando el ScrollViewer está en la parte superior, la posición de la ScrollViewer es 0% y se oculta el botón superior.When the ScrollViewer is at the top, the position of the ScrollViewer is 0% and the top button is hidden. Cuando el ScrollViewer en la parte inferior, la posición de la ScrollViewer es 100% y se oculta el botón de la parte inferior.When the ScrollViewer is at the bottom, the position of the ScrollViewer is 100% and the bottom button is hidden.

Constructores

MenuScrollingVisibilityConverter() MenuScrollingVisibilityConverter() MenuScrollingVisibilityConverter() MenuScrollingVisibilityConverter()

Inicializa una nueva instancia de la clase MenuScrollingVisibilityConverter.Initializes a new instance of the MenuScrollingVisibilityConverter class.

Métodos

Convert(Object[], Type, Object, CultureInfo) Convert(Object[], Type, Object, CultureInfo) Convert(Object[], Type, Object, CultureInfo) Convert(Object[], Type, Object, CultureInfo)

Llamado al mover un valor de un origen a un destino.Called when moving a value from a source to a target.

ConvertBack(Object, Type[], Object, CultureInfo) ConvertBack(Object, Type[], Object, CultureInfo) ConvertBack(Object, Type[], Object, CultureInfo) ConvertBack(Object, Type[], Object, CultureInfo)

No se admite.Not supported.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a