I am new to WPF and was trying to make a Sidebar like menu in my Application. I want to load appropriate windows in the right side (75% of the total width) based on the items selected in the sidebar (located in the left, 25% of the total width). Is that possible?
I dont think you can have Window inside another Window that is one of the difference between UserControl and Window that you cant have Window as child of another Window but you can have one or more UserControls as child.But you can do that using Two Windows one for your Menu and another Window that is going to be according to your selected Item in Menu. But you must set the SideBar Windows TopMost property True.I hope this will give you an idea
Related
let's say I want to make program settings menu like:
Many tab options that change the layout of the rest of the window
My program is in C# and I'm making it in Visual Studio
I tried to do it 2 ways:
Make the window super large with all possible layouts in the Form designer and then just resizing it to fit one of them at the time but this method works for like 4 tabs when you can fit them all at 1 screen. If it's large you have to work with slide bars and that's really impractical, laggy and for many tabs you even have to search them
Not using Form designer at all and hand write all the declarations, positions, sizes, colors etc. But like this it takes pretty a while even just to set up 1 button and there is no way I can fast see how it looks like
So the question is: Is there a magic way I don't know about to do this? And how is this made professionally?
Simple solution for small number of views
You can use a TextBox and ListView docked in a Panel docked left.
And a ControlTab docked fill in a panel named for example PanelMain docked fill at right with visible at false.
You will create any tabpage as option. In each tabpage you will put a panel docked fill and dedicated content in. On the listview item click event or itemchange, you will set the tabpage panel parent to PanelMain.
The little problem can be about spacing and the code file can be large (regions can be used).
Advanced solution more clean for several views
You can use the standard multipage pattern with one form per option/view, and do the same thing as exposed previously.
You create one form per view and put a panel docked fill embedding controls.
When the user click on the menu, you set the form main panel parent to the option form or the main panel of the options form.
I hope I haven't written too badly in unverified English.
Feel free to open any new question centered on any atomic and code problem on this subject.
I have many buttons in winform. it's look like buttons in calculator.
When I open full screen, buttons stays on top left side (same size they were before) and on the right side there is empty background of form.
How can I make them get bigger and stay centered relatively when I open winform on full screen?
If you have 2 or less buttons per row/column, then you can use anchors.
However, if you have more than 2 buttons per row/column, you'll need to use a TableLayoutPanel (granted you don't have an external controls library like DevExpress or Telerik) which you can then dock/anchor accordingly.
You can dock your controls in the center. Try the following:
1) Select your controls through pressing right cursor of the mouse and hovering over your controls
2) Place your controls in the center
2) Go to 'Properties' panel and find 'Anchor' property
3) Deselect all the anchors (default anchors are top and right)
Try running and resizing your Windows Forms application.
I am developing a generic GUI with a windows form in c#.
I have added different buttons and windows on the right panel of the form. What I would like to do is to link these buttons on the right with different subforms (?) which will appear on the left. In particular, when pressing a button on the right panel, I would like to display a new form/userControl/window/or-anything-you-recommend on the left panel of my ParentForm. Should I go with MDI Form? How could I specify where to position each of the child forms on the Parent one?
Many thanks in advance!
My window form contains many sub-components including 2 labels. Now I want if 2 these labels are invisible, the window form automatically shrink in order to fit the remaining sub-components. When 2 these labels are visible, the window form automatically grows up in order to contain all components.
I've used the following properties of the window form, but it does not work:
1) AutoSize = true
2) AutoSizeMode = GrowAndShrink
Is it possible for a window form to implement such feature? Otherwise, I have to do it manually??
Thanks
The window will autosize so that all control fits inside the window. If you make the labels invisible they will still be there and stop the window from getting smaller.
if I got your question right you can achieve this with Multiview...take a Multiview from toolbox and add two view in it (from toolbox) in design mode choose Multiview and in properties panel set the active view index on 0 (by default the value is -1)...put the both of the label in which you willing to hide in one view and let the other stay blank...so now in C# you can switch between the views as you please with a command like MultiView.SetActiveView(View1)...as you can see when you use this method basically there is no label when you switch on the blank view so there is no unnecessary white space in your form
I am making a webbrowser and I have to make the tabs draggable. So when you pull out a tab, I delete the tabitem from the tabcontrol and put it in another window, which I create on that very moment, and that's the tab, the window, you drag. Now I have to be able to drop the tab back in so I need to check if the window, the window I am dragging, is over another window where it could be dropped.
So I actually need two things:
1) Is the window over another one?
2) If it is over a window, is it the first window underneath the window youre dragging?
Thanks in advance
This should give you a good starting point Drag and Drop Overview