Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C# WPF vertikale Scrollbar auf Grid setzen

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe ein Problem in WPF auf ein Grid eine vertikale Scrollbar zu setzen. Ich möchte innerhalb dieses Grids TextBoxen scrollen können.

Bis jetzt gibt es eine (leider) unabhängige Scrollbar im Grid selbst.

Ich dachte das geht ähnlich wie in Java, wo ich das JPanel der JScrollPane übergeben kann und dann einfach die JScrollPane anzeigen kann.

Folgende Links lösten das Problem auch nicht wirklich:

Scrolling in WPF « Arcane Code

How do I force the vertical scrollbar in a DataGrid to always be visible? - Windows Forms FAQs

c# - WPF: ScrollViewer in grid - Stack Overflow

Wenn es geht möchte ich auch nicht mehr vom Grid auf ein anderes Oberflächenelement umsteigen. Über eure Hilfe dazu freue ich mich!

MFG derwunner

  • 3 Wochen später...
  • Autor

Hallo,

sorry der späten Antwort, hatte ein Stück gedauert.

Ich habe es nun so gelöst (Beispiel):


 ScrollViewer viewer = new ScrollViewer();

            innergrd.Children.Add(viewer);

            StackPanel panel = new StackPanel();

            for (int i = 0; i < 10; i++)

            {

                TextBox tb = new TextBox();

                tb.VerticalAlignment = VerticalAlignment.Top;

                tb.HorizontalAlignment = HorizontalAlignment.Left;

                tb.Margin = new Thickness(5, 5, 5, 5);

                tb.Text = "Textbox " + i.ToString();

                panel.Children.Add(tb);

            }


            viewer.Content = panel;

gemäß der Microsoft Hilfe

MFG derwunner

  • Autor

Noch eine Frage:

Wieso kommt eine Exception, wenn ich es versuche so auszulesen?


foreach (Control c in this.m_panel.Children)

{

      o = csyno.GetType();

      if (o == typeof(TextBox))

      {

            tb = (TextBox)o;

            if (tb.Text.Length == 0)

            {

                  MessageBox.Show("Bitte geben Sie etwas ein!");

                  tf = false;

                  break;

             }

      }

}

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.