Dynamic layout of WPF controls, which depends on some state

I am using WPF and I have a problem with prototyping. I have a docked panel (not WPF, I just checked my control inside). And when the user wants to dock this panel to the left or right of the screen, I will need to configure my controls in one way. But when the user wants to dock this panel up or down, I need to expand my controls in a different way.

My question is the best way to implement the dynamic layout of WPF controls, which depends on some conditions?

I understand that I can use the grid and dynamically change the position of my controls inside the grid. But I am not very happy with this decision. I am looking for a solution without code intervention, only for xaml. And in case this is impossible, at least with minimal interference with the code.

Thanks in advance.

+4
source share
3 answers

You can use AvalonDock to get a docking system very similar to a visual studio.
This will give your users full control over the layout they want, and it's not too difficult to implement.

But if you really need a quick way to do this, I would recommend binding the DockPanel.Dock property to the ViewModel value, which changes as the user enters (if necessary, IValueConverter if necessary).

+5
source

To do this, use the DataTemplate function.

The idea is to provide multiple DataTemplates, and then use a custom implementation of the DataTemplateSelector rturn right DataTemplate based on the criteria.

+3
source

Use StoryBoard and change the transformation of controls

+1
source

All Articles