I'm currently working on a school project where I'm asked to develop a C# WPF application. I'm implementing the MVVM design-pattern. This is why my main goal is to avoid using code-behind as much as I can. My main concern is that I'm trying to figure out an effective way around my software's "menu navigation" system.
For example, I'd like to have different windows to update clients, another to manage the employees and so on. My teacher said the best way would be to create an user control and adding it on every single window. How would that work? I would have to be able to detect the click on the user control and opening/loading the correct window according to that.
And if you try to organize your projects in tabs with a TabControl? You can personalize it too!
Related
So I have experience in C++ and I am now messing around in C# .NET with the Windows Forms. I know how to create a new Form, which I can use as a new window. And that you can also create user control, a component or a normal class.
Now I made an application in C++ but I want to convert it to C# .NET. In C++ I made the whole gui myself. But I want to do that now in C# .NET for practice.
In that application, the user could create nodes (Like you can in unreal engine 4 in the blueprints, see example picture)
Now I am unsure what would be the best way to do this in Windows forms.
Making a new form doesn't seem like the correct way. Because the nodes have to be inside of the main screen. And you should be able to move the grid which hold the nodes. So nodes shouldnt be able to exit the main screen that holds them.
Is it better to create it from scratch myself in a class? Or can I achieve this with a user control or component class? I do not understand what the best use of these classes are and what they are used for.
So I want to make something like this, and the question is what is the best type of class to make the nodes with?:
I think you should use WPF to obtain node-base UI. I developed a program with such an interface in WPF and it was pretty simple (I didn't have any experience in WPF):
You can create almost every layout you want using grids, borders, stackpanels, dockpanels, paths etc.
I want to create a kiosk mode application using WPF. I want to use a single window because the user should not be able to exit this fullscreen application.
The application should guide the user trough a process. When the user proceeds trough the process, the screen should constantly change and show him the next step.
Usually I just create a single window and use a "state machine" to switch UserControls containing the information for the current step. Is there a better way to achieve this functionality? Maybe I would get a better result using multiple windows or Pages (never used them).
The reason why I am asking is that in future I want to have a simple, clean way of switching the content inside a single window. i.e. I am planning to implement some sort of animation when switching content (like sliding to the next / previous step). I don't want to put more effort into my current approach if it isn't the most flexible and clean one.
Any ideas?
PS: This is about desktop applications. Today I come from the Winforms environment and am experimenting with WPF.
There's a few ways you can achieve this.
First would be to use a Page based application, this will allow you to use a single window. Here is a pretty interesting tutorial
A bonus of using this approach is that navigation between pages is built in.
Your requirements are that you need to use animation for transitioning between pages, as far as I'm aware, using a Page based application cannot achieve this (I may be wrong). So your other option would be to use a UserControl MVVM approach.
This probably won't make a lot of sense now, but here goes:
You can use a single master view model which will hold multiple child view models, each of these could have a visibility property which dictates the visibility of the associated view. The master view model would simply be responsible for displaying the appropriate view model depending on where the user currently is in the application.
Using some clever XAML, you can create storyboards (animations) when the view becomes visible, which will allow you to achieve the crazy awesome animations that you require.
Anyway, that probably didn't make any sense, so here's a tutorial to get you started with MVVM.
Create own TextBox, Button etc control as own control using User control in C# Windows application, is this good idea?
I wanted make consistency for through out the application. Suppose if I want to change the Textbox border color then all forms textbox updated with this changes. It's just an example.
Please suggest me.
I don't recommend using UserControl just for consistency. If application skinning is what you are after, look into WPF. It makes it relatively simple to skin an application (or even a window, or smaller groups)
Here is an article on skinning with WPF: http://www.codeproject.com/Articles/19782/Creating-a-Skinned-User-Interface-in-WPF
Another alternative, staying within Windows Forms, is creating a class that inherits from TextBox, and using that class throughout the application. The Factory pattern would work well here. You could even adapt it to multiple skins.
It's not a bad idea to provide custom controls that match your "User Experience" (UX). It really just depends on what you are trying to accomplish with your program.
I'm pretty new to WPF and C#. I am looking to create multiple windows with in one primary window, like creating forms and subforms in Microsoft Access. I would like to work with One main .xaml and have two seprate .xaml's that the user will open with a button selection. I do not want to have multiple windows pop up (if possible). Instead I would like the main .xaml to display the selected .xaml with-in itself.
Create a User Control and switch the visualization, more examples: http://windowsclient.net/learn/video.aspx?v=76360
You can user user controlls for this. This is a good walkthrough http://www.codeproject.com/KB/WPF/UserControl.aspx
As the other individuals have said, you'll want to create a User Control. It's fairly good practice to create User Controls where possible if you'll be re-using the code.
All in WPF:
Developing a wizard application, user has to answer a number of simple questions before brought to the main app. The main app is then prefilled with the information obtained from the wizard.
I started with a Window which I then planned to add usercontrols to. The main window would have the user control in the first row, then Next and Previous buttons to control moving between the controls in the second row. This way I could easily control the logic to switch between screens like:
WizardControl1.IsVisible = false;
WizardControl2.IsVisible = true;
But for some reason, user controls do not have setter for IsVisible. Hurray.
So then I thought I would just use seperate windows for each section of the wizard. The problem with this approach is that now when stepping between, the window opens in random positions, and by steppign through the wizard with next, the next window pops up randomly which is really distracting and frustrating.
So how can I develop a wizard properly? I don't get why this is so hard...not exactly rocket science... replacing text and controls and storing input after pressing next/previous!
Thanks
Check this link:
http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx
This is the article about building wizard in WPF by Josh Smith, it's seems to be nice pattern.
I found it's helpful for me, hope you'll too.
There is also an open source Avalon Wizard control on codeplex.
I'd probably aproach this using data binding and template selectors. Have the wizard form bind to a "WizardData" class, which exposes a list of "WizardPage" base classes.
The WizardData class can expose properties defining the correct info on the forms, and display a control for the main page that uses a template selector to determine the proper control to display based on the actual type of the particular wizard page.
It sounds like more work than it is, really. It also gives you the benefit of good separation between code and UI (all "work" is done by the WizardData and WizardPage classes), and the ability to test logic independent of the UI.
It's also a very WPF/MVVM way of approaching the problem.
I recognize this does not directly address your question, but I thought I'd mention it as a possible alternative. I've used Actipro's Wizard control with pretty good results, and when I have needed support, they have been very responsive. I am not affiliated with them in any way; I just like not having to write the plumbing to manage a wizard.
The property is called "Visibility".
I find that I do better when I dynamically add and removing controls rather than hide them.
I was looking for a Wizard solution too. I have the need to stick with stock WPF components so I implemented the wizard using a standard form and a tab control.
I only hide the tabs at runtime so there available in the IDE. At runtime just use Back, Next, Finish... to navigate thru the tab items
works good