ScrollViewer not scrolling in WPF

后端 未结 5 635
滥情空心
滥情空心 2020-12-09 01:45

I am using a scrollviewer control around my stack panel which contains an ItemsControl. When there are many items in the ItemsControl it is suppose to scroll but for some re

5条回答
  •  隐瞒了意图╮
    2020-12-09 02:06

    I had a problem whereby I showed an ItemsControl in a Grid and in order to see the scrollbars, I had to give this Grid cell *-sized height.

    However, this meant that the ItemsControl always filled the cell even when there were only a few values.

    I wanted the ItemsControl to be only big enough to show what it had but if it had too many items then I wanted it to scroll. In order words I wanted this to work only any size monitor.

    This code in the Loaded event worked for me:

    Size x = new Size(double.PositiveInfinity, double.PositiveInfinity);
    myItemscontrol.Measure(x);
    

提交回复
热议问题