ScrollBarVisibility Énumération

Définition

Spécifie la visibilité d'une ScrollBar pour un contenu déroulant.

public enum class ScrollBarVisibility
public enum ScrollBarVisibility
type ScrollBarVisibility = 
Public Enum ScrollBarVisibility
Héritage
ScrollBarVisibility

Champs

Auto 1

Une ScrollBar apparaît et la dimension du ScrollViewer est appliquée au contenu lorsque la fenêtre d'affichage ne peut pas afficher la totalité du contenu. Pour une ScrollBar horizontale, la largeur du contenu a la valeur ViewportWidth du ScrollViewer. Pour une ScrollBar verticale, la hauteur du contenu a la valeur ViewportHeight du ScrollViewer.

Disabled 0

Une ScrollBar n'apparaît pas, même lorsque la fenêtre d'affichage ne peut pas afficher la totalité du contenu. La dimension du contenu a pour valeur la dimension correspondante du ScrollViewer parent. Pour une ScrollBar horizontale, la largeur du contenu a la valeur ViewportWidth du ScrollViewer. Pour une ScrollBar verticale, la hauteur du contenu a la valeur ViewportHeight du ScrollViewer.

Hidden 2

Une ScrollBar n'apparaît pas, même lorsque la fenêtre d'affichage ne peut pas afficher la totalité du contenu. La dimension du ScrollViewer n'est pas appliquée au contenu.

Visible 3

Une ScrollBar apparaît toujours. La dimension du ScrollViewer est appliquée au contenu. Pour une ScrollBar horizontale, la largeur du contenu a la valeur ViewportWidth du ScrollViewer. Pour une ScrollBar verticale, la hauteur du contenu a la valeur ViewportHeight du ScrollViewer.

Exemples

L’exemple suivant montre comment utiliser les valeurs membres de cette énumération pour définir la HorizontalScrollBarVisibility propriété du ScrollViewer contrôle.


// Create the application's main window
mainWindow = gcnew System::Windows::Window();
mainWindow->Title = "ScrollViewer Sample";

// Define a ScrollViewer
myScrollViewer = gcnew ScrollViewer();
myScrollViewer->HorizontalScrollBarVisibility = ScrollBarVisibility::Auto;

// Add Layout control
myStackPanel = gcnew StackPanel();
myStackPanel->HorizontalAlignment = HorizontalAlignment::Left;
myStackPanel->VerticalAlignment = VerticalAlignment::Top;

TextBlock^ myTextBlock = gcnew TextBlock();
myTextBlock->TextWrapping = TextWrapping::Wrap;
myTextBlock->Margin = System::Windows::Thickness(0, 0, 0, 20);
myTextBlock->Text = "Scrolling is enabled when it is necessary. Resize the Window, making it larger and smaller.";

Rectangle^ myRectangle = gcnew Rectangle();
myRectangle->Fill = Brushes::Red;
myRectangle->Width = 500;
myRectangle->Height = 500;

// Add child elements to the parent StackPanel
myStackPanel->Children->Add(myTextBlock);
myStackPanel->Children->Add(myRectangle);

// Add the StackPanel as the lone Child of the Border
myScrollViewer->Content = myStackPanel;

// Add the Border as the Content of the Parent Window Object
mainWindow->Content = myScrollViewer;
mainWindow->Show();

// Create the application's main window
mainWindow = new Window ();
mainWindow.Title = "ScrollViewer Sample";

// Define a ScrollViewer
myScrollViewer = new ScrollViewer();
myScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;

// Add Layout control
myStackPanel = new StackPanel();
myStackPanel.HorizontalAlignment = HorizontalAlignment.Left;
myStackPanel.VerticalAlignment = VerticalAlignment.Top;

TextBlock myTextBlock = new TextBlock();
myTextBlock.TextWrapping = TextWrapping.Wrap;
myTextBlock.Margin = new Thickness(0, 0, 0, 20);
myTextBlock.Text = "Scrolling is enabled when it is necessary. Resize the Window, making it larger and smaller.";

Rectangle myRectangle = new Rectangle();
myRectangle.Fill = Brushes.Red;
myRectangle.Width = 500;
myRectangle.Height = 500;

// Add child elements to the parent StackPanel
myStackPanel.Children.Add(myTextBlock);
myStackPanel.Children.Add(myRectangle);
            
// Add the StackPanel as the lone Child of the Border
myScrollViewer.Content = myStackPanel;

// Add the Border as the Content of the Parent Window Object
mainWindow.Content = myScrollViewer;
mainWindow.Show ();

'Define a ScrollViewer.
Dim myScrollViewer As New ScrollViewer
myScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto

'Add Layout control.
Dim myStackPanel As New StackPanel
myStackPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Left
myStackPanel.VerticalAlignment = System.Windows.VerticalAlignment.Top

Dim myTextBlock As New TextBlock
myTextBlock.TextWrapping = TextWrapping.Wrap
myTextBlock.Margin = New Thickness(0, 0, 0, 20)
myTextBlock.Text = "Scrolling is enabled when it is necessary. Resize the Window, making it larger and smaller."

Dim myRectangle As New Rectangle
myRectangle.Fill = Brushes.Red
myRectangle.Width = 500
myRectangle.Height = 500

'Add child elements to the parent StackPanel.
myStackPanel.Children.Add(myTextBlock)
myStackPanel.Children.Add(myRectangle)

'Add the StackPanel as the lone Child of the Border
myScrollViewer.Content = myStackPanel
Me.Content = myScrollViewer
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      WindowTitle="ScrollViewer Sample">
  <ScrollViewer HorizontalScrollBarVisibility="Auto">
    <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
      <TextBlock TextWrapping="Wrap" Margin="0,0,0,20">Scrolling is enabled when it is necessary. 
      Resize the window, making it larger and smaller.</TextBlock>
      <Rectangle Fill="Red" Width="500" Height="500"></Rectangle>
    </StackPanel>
  </ScrollViewer>
</Page>

Remarques

Utilisez cette énumération pour définir les valeurs et VerticalScrollBarVisibility les HorizontalScrollBarVisibility valeurs de propriété du ScrollViewer contrôle.

Les valeurs membres de cette énumération spécifient ScrollBar une visibilité dans une direction donnée. Ces valeurs de membre spécifient également si la dimension correspondante ScrollViewer est appliquée à son contenu entouré.

Lorsque vous appliquez le ViewportWidth contenu ou ViewportHeight le ScrollViewer contenu, vous définissez la taille de la fenêtre d’affichage pour le contenu.

S’applique à

Voir aussi