简体   繁体   中英

WPF 3 panels with seperate content or 1 panel with dynamically generated content

I am creating WPF application that utilizes a simple navigation menu. When one of the menu items is selected, I want a grid control with buttons to become visible.

I have 3 items on my navigation menu. For purposes of speed and better coding practice, is it better to have 3 seperate grids and they all are visible until the button is clicked and one becomes visible or is it better to have just one whose content gets changed depending on what button is clicked?

I'd prefer to use a container control (eg ListBox ) instead of a grid. This way you can bind one of your three menus to this container control's DataContext , depending on the button clicked.

If your menu entries are static you could also use a content control and change the ContentTemplate . All three neccessary ContentTemplates can then be defined in XAML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM