.NET WPF application UI structure - c#

I'm fairly new to WPF and .NET in general. What I am trying to do is to create an application that has multiple forms. My question is that how should navigate through these forms?
Imagine there are 10 forms and each form has a button on it saying "Next" and upon click, goes to the next form, except the last form which terminates the entire application, like an installer if you will.
What should the "Next" buttons do? Should they create a new object of the next form and close the current form? I noticed this has a closing/opening visual effect which made me realize maybe I'm not doing it right.

What you need is a Wizard like approach.. look at this thread
Developing wizard UI - WPF

Related

Adding another page to windows form application - c#

I am quite new to C#. I am creating a Windows Form Application in Visual Studio 2017 and I was wondering how I link one page to another? e.g. clicking on next which will guide the user to the next page. I do not know the exact words for how to explain this but my research as of now has been quite useless.
I would like to know if I need to create another form? or simply add a new item to the existing form.. I am just not sure. Any help would be great thank you.
Sorry if unclear: E.g.
I have a form I am creating, which requires several details which should be on different stages of the app? I am wanting to have a next button which moves the user from the first page where it may have textboxes to a next page (which I will create - depending on how it works) where there may be radioButton questions.
If you want to project the new page in separate dialog or window just create separate form and trigger the open function of the form when next button is clicked.
If you want to project the new page in the same dialog then use tab control in that same form and make some validation to switch to next tab when next button is clicked.
Note: Using tab control is the best idea for your case.

Common Ribbon Control in Windows Forms

I want to develop windows forms application in which i want same ribbon control to appear on top with same Click Functions associated. Is there any solution to add same ribbon to all forms? I tried MDI, but i dont have requirement of multiple documents to be opened at same time. I tried adding same ribbon to all forms one by one, but then , i need to create click methods for all buttons in all forms seperately, that is tedious and time waste.
Also, i need to know any solution for smoothing transition between form change. When i use code:
Form f1=new Form();
f1.show();
this.hide();
This works correctly for switching between forms, but the problem is it creates a jerk on screen. So, is there any solution for smooth transitioning of forms?
You could create a base class that implements the ribbon. Just reuse (that is: derive from) that control for every form you have.
Create a container under the ribbon where you can put your actual form content in.
A problem might be that the designer often doesn't like this, so it might be quite some work to smooth thing out.

What's the equivalent of calling Activity.finish() in a WinForms application?

In Android when finished with an Activity and want to return to previous activity you use finish();.
Is there an equivalent in WinForms using C#? In my application once the user clicks the Enter button I want the user to return to previous window.
Base on a superficial understanding of an Activity in Android (sounds like a window element), you just need to call Close on the current window, then the previous one will then move to the foreground.
For future reference however, I would advise you not too create such analogies between two radically different technologies since the life cycle of an Activity in Android is radically different from a form in a Windows Form application. You should try to learn the framework rather than replicating an implementation from a different framework/platform.

How to have a user navigate multiple "screens" within one form/window?

I am working on a project that simulates a company's program for performing various functions within a GUI (using C# on VS2010). Currently there are about 10 or so different forms, one for each function (serving as a menu, filling out assorted forms, management of said forms, ect). So far we've been using things along the line of:
Form1 myForm1 = new Form1();
myForm1.Show();
to open new screens and
this.Hide();
when finished with the currently active form. (this.Close() just seems to close the entire program)
This causes some issues in that the process has an issue of continuing to run after the X at the top right of the form is clicked (I think that this is due to hidden forms not being closed properly). I also suspect that if a user uses in-program navigation without killing the process long enough, the constant generation and hiding of forms will end up hogging up all the memory.
In the wild, I rarely see programs that rely on opening new windows/forms constantly to enable user navigation. Programs, such as an installer, typically use an event of some sort to cause the current displayed content to disappear and new content to appear without changing to a new form/window. How can I go about doing this? Is it a matter of having buttons/textboxes/labels all stacked on each other in the one screen, but hidden or is there something more intuitive that I am missing?
Have you looked in to using some kind of MDI setup: http://www.codeproject.com/Articles/7571/Creating-MDI-application-using-C-Walkthrough
The way you can do this (but isn't always feasible) is to make a UserControl for each screen. When its time to move on to the next screen, you simply hide the current user control and show the next one. So if you have 8 screens for example, you make each one into a user control.
Then on your MainForm's Load event, you initially hide all except the first one. When its time to move onto the second screen, you hide the first control and show the second, etc etc

Windows Mobile- only keeping one form open. Best design question

So I would consider myself a .Net and ASP.NET pro but I am a bit new to Windows Mobile (I am targeting .net 3.5 CF and Windows Mobile 6).
I am creating a data driven application that will have 3-4 tables. I have created a form for each table that allows the user to search through the table.
Each form inheretes from the Main form so that they each have the same Menu.
My question is how do I make sure that only one Window is open. I want to allow the user to go to the menu and choose a table which will open a new form. What I don't want is for the user to open say each form and then when they are done to have to close 3 or 4 windows. Is this possible? If so how do I do it? On a side note is there a better way to do this. I don't want all my logic on one form. So I don't just want to hide and show and panels.
I keep something I call an application hub that everything goes though.
So each menu click will call the applciation hub, and each form will reference it.
Then, when switching form, the application hub needs to keep track of the current form, close it, then load the requested form.
This isn't much code to write, and performs well.
Or...performance wise, keep the application hub idea, and keep the dialogs open. It will perform better that way, rather than having to reload the forms all the time.
Then on shut down, the application hub can check which forms are open (it should have a reference to each running form) and close them for the user.
Instead of having multiple Forms (inherited form mainForm) you could put the table stuff on UserControls and have total control about their Creation/Destruction/Visibility much easier.
Use an Interface or a BaseUserControl to implement common functionality.
This article, while not exactly what you are asking, was very helpful when I was redesigning a .NET CF application: Creating a Multiple Form Application Framework for the .NET Compact Framework
My application required a bit of both worlds - I wanted to have a single form open, but also sometimes wanted to stack a secondary form on top of the first (eg. if they go to a Prefs page or some other type of form where they should only ever dismiss it after a moment).
(Pseudo-coding after this)
I created a ViewManager and implemented it as a singleton. When the app first launches, I call ViewManager.GotoForm(frm). This sets the current form to be whatever form I need.
Then I immediately call ViewManager.CurrentForm.ShowDialog() - I'm sure there's a better way, but I found I had to call ShowDialog() at SOME point just to get a form to appear.
Subsequent calls to ViewManager can take the form .ReplaceForm or .StackForm. The differences should be fairly intuitive.
What you can also do in a view manager like this is cache forms that aren't being displayed, but probably will be again and have expensive setup costs (for instance, in a data-driven app you might have to query the database to determine the fields or tables to display on a form, and this won't change at runtime).
The trick here is that you never call .Show() or .ShowDialog() anywhere in your application - you route all form navigation through the view manager which handles loading the next instance of your form, disposing of old forms (if not being cached), and dispatching any sort of populate logic if you want to pass new data to a form's UI before it loads.

Categories

Resources