How design left menu panel - c#

in windows wpf i want design a left bar menu like this:
when i click on an item, in the right the window change.
With which control can i design this?
Tab bar control?
Or a left dock panel and insert inside it some button? In this case how can I change the window on the right when click on a button?

If each time you click on a button you want to display a different view, you could define each of your views in a separate control and in your main window within a grid declare each view in a DockPanel.
Then by binding the visibility property of each DockPanel you can create the logic in order to display only what you want on each click.

I suggest using a styled ListBox and binding the Visibility property of your content to it. Even better you can also use a styled Tab control.

Related

WPF MVVM Change button content with loading user control

I have a simple window with two buttons on bottom, when one button is clicked it change the view model of my main window, the name of the content button and the command.
I would like that when user click on the button change this with a loading user control i already have but i'm stacked, i don't know it's something i can implement with xaml or i need some code on my view model.
Any suggestions would be appreciated.
Thanks.
You will need some code on your ViewModel to swap out the Button for the Loading control. You can either do this with binding ContentControls or with a Boolean property to set one to visible and the other to hidden while the loading happens.

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 (e.g. 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.

Open a Popup from a Scrollviewer

I'm making a WinRT application using XAML and I have a control that has a TextBox and a Popup that opens under it when the TextBox get focus.
The Width of the Popup is the same as the Width of the TextBox. This works fine but if I put my control in a ScrollViewer and zoom in the size of the popup doesn't change. I would like to achieve something similar to the standard ComboBox which changes the size of its Popup when it is nested in a ScrollViewer. What should I do?
I know that the popup must be part of the VisualTree but I'm not quite sure how to add it without changing the existing layout.
Thank you
To have the popup be parented in the TextBox you can either modify the template of the TextBox and put it in there (you could subclass TextBox to both add support for your dropdown logic and change the default template at the same time) or simply find the root Grid of the TextBox using VisualTreeHelper. By default TextBox has a Grid at its root, so you could get that and add the Popup to its Children.

Show UserControls In "ItemsControl" with custom option in XAML

I have a ItemsControl in ScrollViewer and I set ItemsPanel of my ItemsControl to Horizontal StackPanel and i bound it to ObservableCollection of userControls.Now I wanna when user click on icons of open UserControls in my ItemsControl,automatically scrollviwer's offset change to show icon clicked UserControl.( I have a Icon for my each usercontrols)
And also when user open new UserControl ,I wanna my ItemsControl automatically show it ( now when I open a new usercontrol i should scroll my ItemControl to reach it),
can I do this with above controls ,if yes, can you tell me how? If not, I appreciate to tell me which controls should I use controls and how?

Should I be using a WPF user control? Or just a Grid?

So I have an application that is split into 2 parts - on the left there is a custom menu, on the right a grid that holds all the "content" (different screens).
It looks something like this:
Also, when the different buttons are hit, the menu on the left will fill up with different buttons (for example, if you hit the review button, the menu would become something along the lines):
Start Date
End Date
Employee
Project
...
I am pretty sure that I want each of the screens (to go on the right) to be their own user controls.
But my question is this: Should each of the menu's be user controls? This makes it a little harder to use them. Then I have to worry about having getters/setters so the main window can listen on the menu's buttons, etc.
The other option is to just programmatically add the buttons in the mainWindow, this way I can just add the listeners right in mainWindow.cs (into a grid)
Which is the better method? Or is there another method which is favoured?
The entire window can be done easily as a Grid.
The left side can just hold a StackPanel or other layout control with your buttons.
You can use a ContentPresenter to hold the content on the right. When you trigger your buttons, just change the bound content, and it will update with your appropriate user controls.
I think you might do it with a grid as Reed told. But if you will need to reuse this in another place, I think you should use a separated UserControl instead.
Maybe I'm misunderstanding you, but I would use a TabControl, with TabStripPlacement="Left".
If you need extra space on the left to display other stuff, you can override the default TabControl's ControlTemplate and add a bunch of margin space to the TabPanel inside the ControlTemplate. Alternatively, you could have the TabItem's header display differently when it is selected versus when it is not selected.

Categories