WPF window scrolling with top menu
I'm running into a dilemma. When I make the ScrollViewer the main content object of my window, scrolling behaves exactly like I want it to. You resize to make it smaller than the content and the window and scroll bars appear. The problem comes in when I want the to menu to be static and the rest of content to be scrollable. I want the scroll bars to behave the same way as a browser window does, meaning when you resize it, the scroll bars appear ba开发者_开发问答sed on the size of the content. When you expand the window, the content takes up the entire real estate of the window. Is that possible in WPF?
Help would be GREATLY appreciated.
Make a DockPanel
the main content object of your window. Insert your top menu as the first child (with DockPanel.Dock="Top"
) and the ScrollViewer (containing the rest of the window's content) as the second child. In a DockPanel, the last child takes up all the remaining space, which should be what you want.
<Window ...>
<DockPanel>
<MyMenu DockPanel.Dock="Top" ... />
<ScrollViewer>
....
</ScrollViewer>
</DockPanel>
</Window>
精彩评论