How to Add a Scrollbar to Window in C#

后端 未结 3 2012
你的背包
你的背包 2021-01-07 18:05

I have created a window as follows:

Window myWindow = new Window();

How can I add a Vertical Scroll Bar to this Windows and make the Scroll

3条回答
  •  被撕碎了的回忆
    2021-01-07 18:58

    You cannot add a scrollbar to a window itself. You can only add scrollbars to controls. I.E. to a grid inside your window.

    Example:

    
       ...
    
    

    EDIT:

    Just realized that Window also has a ScrollViewer property. I'm not sure how this property works for a Window and how such a window would look like. Gave it a try, but no scrollbars show up.

    EDIT 2:

    ScrollViewer sv = new ScrollViewer();
    sv.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
    myGrid.Children.Add(sv);
    

提交回复
热议问题