ScrollBarVisibility Výčet

Definice

Určuje viditelnost posunovatelného ScrollBar obsahu.

public enum class ScrollBarVisibility
public enum ScrollBarVisibility
type ScrollBarVisibility = 
Public Enum ScrollBarVisibility
Dědičnost
ScrollBarVisibility

Pole

Auto 1

Zobrazí ScrollBar se a rozměry ScrollViewer obsahu se použijí, když zobrazení nemůže zobrazit veškerý obsah. Pro vodorovnou ScrollBaršířku obsahu je nastavena na ViewportWidth hodnotu ScrollViewer. Pro svislou ScrollBarvýšku obsahu je nastavena na ViewportHeight hodnotu ScrollViewer.

Disabled 0

A ScrollBar se nezobrazuje ani v případech, kdy zobrazení nemůže zobrazit veškerý obsah. Dimenze obsahu je nastavena na odpovídající dimenzi nadřazeného objektu ScrollViewer . Pro vodorovnou ScrollBaršířku obsahu je nastavena na ViewportWidth hodnotu ScrollViewer. Pro svislou ScrollBarvýšku obsahu je nastavena na ViewportHeight hodnotu ScrollViewer.

Hidden 2

A ScrollBar se nezobrazuje ani v případech, kdy zobrazení nemůže zobrazit veškerý obsah. Dimenze obsahu ScrollViewer se nepoužije.

Visible 3

Vždy ScrollBar se zobrazí. Rozměry obsahu ScrollViewer se použijí. Pro vodorovnou ScrollBaršířku obsahu je nastavena na ViewportWidth hodnotu ScrollViewer. Pro svislou ScrollBarvýšku obsahu je nastavena na ViewportHeight hodnotu ScrollViewer.

Příklady

Následující příklad ukazuje, jak použít členské hodnoty tohoto výčtu ScrollViewer k nastavení HorizontalScrollBarVisibility vlastnosti ovládacího prvku.


// 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>

Poznámky

Pomocí tohoto výčtu můžete nastavit HorizontalScrollBarVisibility hodnoty vlastností VerticalScrollBarVisibility ovládacího ScrollViewer prvku.

Hodnoty členů tohoto výčtu určují ScrollBar viditelnost v daném směru. Tyto členské hodnoty také určují, zda je odpovídající ScrollViewer dimenze použita na jeho uzavřený obsah.

Když použijete ViewportWidth obsah nebo ViewportHeight obsah ScrollViewer , nastavíte velikost zobrazení pro obsah.

Platí pro

Viz také