Winforms - how to create something similar to a master page? - winforms

I'm trying to build an app in winforms with something similiar to masterpages in asp.net - a menu on top and when choosing an option from the menu the entire screen on the bottom will change while the menu remains (there are 10-15 screens in the future app, some are quite similar, some are not).
What is the best way of doing this? Should I use different forms for each screen or use a panel or something else?
If I use a panel or something how do I manage to use the designer with so many panels taking space on the screen?

Try with the MDIParent Form's. View the Example
http://www.codeproject.com/Articles/12514/Multi-Document-Interface-MDI-tab-page-browsing-wit

If it is just keeping the same menu and opening/closing parts of the UI you could simply add and remove instances of usercontrols to the main form.
If you need more features such as docking (like Visual Studio) look at this
Another option is to use Form inheritance
Which one to select depends on what you want to reuse and the features you need.

One option would be to make your application an MDI window and then load entire forms, maximized, into the parent window.
Then, you would be able to treat each form as its own self-contained item, since it really would be exactly that.
Is it not an option for you to use WPF? A WPF browser application fits the paradigm you are describing quite well.

Related

WPF dynamic content tabs NOT suitable substitute for MDI user interface

So I have this old PowerBuilder MDI application (medium enterprise app with about 40 windows), and I'm embarking on designing my very first WPF MVVM C# application to replace the aging PowerBuilder app. I've got plenty of C# & .NET experience, but this is my first WPF & MVVM app.
After reading many forum postings after searching for WPF & MDI alternative, I've come to the conclusion that the MDI isn't supported, and that the most commonly proposed substitute is to use the TabControl and dynamically generate the content of each tab page upon demand using a WPF User Control. I had initially been sold on this, and was actually excited by my initial prototype interface with a tabbed Ribbon bar at the top of the app, and the TabControl with the tabs of the app underneath that. However, I have hit a BIG brick wall.
Take a look at the following screen shot of one of the central multi-tab windows from my old application: http://www.creativedatatech.com/downloads/screenshot.jpg
As you can see, the app has a toolbar across the top and the left side, and the example MDI child window (Case Edit Window) that is open has a LOT of tab pages (18 of them), and the users really like being able to quickly click on a tab page to get directly to that information to work on it. Moreover, the users have grown accustomed to being able to open multiple Cases at once and either put them side by side (large monitors), or flip back and forth, possibly copying & pasting between them.
The problem here is that I cannot envision how I am going to incorporate all this multi-tab user experience for the Case Edit Window into a single tab of the top level WPF TabControl. Will the users end up seeing a row of tabs for the WPF TabControl, with one tab for each Case Edit Window that is open, and then inside each "Case Edit" tab page, a further nested set of 18 tab pages?? This seems confusing and a big mess of nested tabs. Add to that the tabs of the Ribbon control at the top of the app, and I think my users will be running after me to lynch me!
After investing two straight weeks reading up on WPF and MVVM, I am left with the sinking feeling that WPF really isn't going to fly well for enterprise apps such as mine.
Surely this can't be true! Does anyone have any comments on how I should go about shaping this app to accomplish what I'm trying to do here? I've already looked at WPF "pages", but I can't have the users serially navigate through all the individual pages to get to the content that they need to work on, and they need to be able to quickly (and visually) navigate to the Case Edit Window content that they need.
I think your problem is not so much WPF, but rather that GUI paradigms have moved away from the MDI that your current app uses. There is nothing stopping you implementing MDI in WPF, but what would be the point if your app ends up looking like it does now?
You really need to think about how to layout your app in a modern way. Perhaps you could keep your tabs for the different cases, but replace the multiple tabs in each child window with a master/detail view, much like Dev Studio does for its Options dialog?
We had this same dilemma, we decided on screen tabs at the bottom with tabs that relate to that screen at the top - and contextual ribbon items.
The tabs in the screens actually just scroll the window to the desired point so all information is sectioned off and available on each screen by scrolling or clicking the tab at the top.
Looks like this

Frames vs User controls in WPF

I'm writing a Windows application in WPF. I based my UI in a single menu and a tab control to display different documents or application forms. Since the menu as well as other things are fixed throughout the application, I need a way to display the contents of each TabItem. I have found two:
write a user control for each form, or
using a frame to display the content of each form.
The question
Is there any other single way for doing this. How do they compare in terms of clean code? I mean, in .net forms I only need load the form from the menu.
I know, I should go for any pattern like MVVM, but for this very first time I want to use the default approach.
I go with Frames and host Pages (not user controls). I like Pages over User Controls as the event model seems to have more hooks.

Winforms application menu and application UI

I am working on a little WinForm app and have been trying to find the answers to a few questions i have without any luck. Im a ASP.NET developer so WinForms development is new to me.
Here is my main question:
How do I create a menu system that once selected the contents will render in the Main form of the selected item. If its a GridView I want to the GridView to render inside the main application so they can navigate away without having to deal with the modal popup. I do not want to popup forms unless i explicitly say so. I guess the equivalent to this would be using a Master page in ASP.NET.
Make sense?
The closest thing to Master pages in winforms would be MDI (multiple document interface), which is a hideous Windows 3.1-era abortion of a user interface. Why this option is even still around, and why anyone still uses it, is beyond me.
The second closest thing (and something more acceptable as a UI) is just to have one main form in your application, and implement the different pieces of functionality your app requires as separate user controls which are displayed on the form and hidden as the context requires.
A weirder method, but one that might also work for you, is to use forms inheritance - design one "master" form with the menus and controls that you want to always be present, and then have each form in your app inherit from that master form. This would not appear to the user to be much different from my second option above, so I wouldn't bother with it.
There really isn't anything similar to Master pages in WinForms.
The closest to what you want to use would be a TabControl selecting a different tab will display that tab over the other tabs. If you don't like the tab look you could extend the TabControl to not show the tabs or hack it together by placing the TabControl inside a panel just large enough to show the content but not the Tabs and change tabs programatically in your menu control.

WPF ControlTemplate How to

I am very new to WPF, about 4 hours new. I am coming from ASP.net and Masterpages.
I was looking at examples of Control Template that can used to template a window so all windows look the same.
Other post
Can some direct me to an example of how it is accomplished or sample code from start to finish?
Second part:
Is the ControlTemplate the best way to go about building WPF windows client applications? What is best practices in architecting WPF windows applications.
Thanks
There really isn't a "best" way to architect WPF UIs. It all depends on the user experience your application will have.
If you want a very web-like experience you are probably better of using the pages constructs. Otherwise if you have windows, but want a common header, you may just want to make a control template for that. Maybe you need separate windows or maybe you just need to have a sub part of a grid panel change content depending on state... There are different ways to do things that are more or less suited to the type of client experience you want.
Although there are some best practices in relation to using MVC/MVVM design patterns, there isn't a "best" way to style and theme your controls. I don't consider WPF as friendly to newcomers as WinForms were, but at the same time it seems a lot more powerful in the long run. What might help you out are some basic levels of theming:
Styles: these are mainly aesthetic changes to the look and feel of basic controls and elements with some very basic support for triggering things like mouse cursor roll over. They are similar to CSS on webpages.
Control Templates: these are the more heavyweight versions of styles where you actually reconstitute a control so that, say a button can have a textbox inside of it. Where styles work on a logical level where something like a button is the most atomic element, control templates can drill down further into controls so that the border, background, text, etc of a button are seen as separate elements instead of one atomic part.
Data Templates: A more focused version of control templates meant to customize how data items in lists are drawn. If you have a bunch of pictures you don't want the file name to show up in the listbox, you'd rather have the image itself. A data template lets you accomplish this kind of thing.
So you have to ask yourself when you say, "Make all windows look the same," do you mean changes are merely aesthetic/looks (styles), customizing how a collection of items are displayed (data/item templates) or altogether changing how a standard control looks and behaves or making sure the layout of controls on a page are the same across multiple windows/pages (control templates)?
Finally, the "end to end" of the other post you linked to is pretty simple. You take the control template there, and under your tag you simply add Template={StaticResource MyTemplateName} and the template is applied. This article on MSDN is a decent intro to control templating.

What navigation control would you choose to use in your application?

ToolStrip with MenuStrip or RibbonBar?
It combines both of the controls. It also have a TabPages navigation, contextual tabs, etc. However the RibbonBar is a very complex control and when you open a new document in for example Word2007 the half of the screen you see a Ribbon Bar. It is not cool. When you have toolStrips you can layout them to Top, Bottom, Left, Right and have more control of the UI look. We can also hide the toolstrips which we do not want to see and they no longer take any screen space.
Ribbon Bar
It boils down to what you're trying to navigate and how complex do you want the Navigation to work.
I prefer to use simple existing applications to base my programs.
Thus for the most part I use either the MenuStrip + X ToolStrips or just a simple ToolStrip if a menu is more involved than is required to get a task done.
But I would have to guess that many people like the Ribbon Bar since it combines the functionality of both Menu and ToolStrips into one control.
Ribbons look more modern, and will help to give you application a modern and current look.
As for usability, I've preferred the experience, as long as you are unfamiliar with the app.
For apps where you are used to a menubar, it's a difficult change, but for new apps or new users it's a good improvement.

Resources