Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic layout of WPF controls which depends on some condition

Tags:

c#

layout

wpf

I'm using WPF and I have a problem with layouting. I have got a docked panel (non WPF, I just hosted my control inside). And when a user wishes to dock this panel on the left or the right of the screen, I need to layout my controls in one way. But when the user wishes dock this panel on top or bottom, I need to layout my controls in another way.

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

I understand, that I can use the grid and dynamically change positions of my controls inside the grid. But I am not really happy with this solution. I'm looking for a solution with no code intervention, xaml only. And in case this is impossible, at least involving minimum intervention in the code.

Thanks in advance.

like image 965
pingvinius Avatar asked Jan 18 '23 09:01

pingvinius


1 Answers

You could use AvalonDock to get a docking system very much like visual studio's.
This would give your users full control on the layout they desire, and it's not too hard to implement.

But if you really want a quick way to do this, I'd recommand Binding the DockPanel.Dock property to a ViewModel value that changes upon user input (along with an IValueConverter if necessary).

like image 142
Louis Kottmann Avatar answered Jan 21 '23 10:01

Louis Kottmann