How to create WPF application with multiple XAML files? - c#

I am developing a simple WPF application and I can create a single MainWindow with controls, content, etc.
However, I want to split my app. And I have a problem to build an app with welcome screen where user can choose between two modes, as seen below:
After click on Learn button I want to load this XAML:
And after click on Next (from Learn screen) or Recognize (from Welcome screen) I want to load this XAML:
...everthing in the same MainWindow.
I can't even name what I am trying to achieve. Do I want pages? Or views?
How to handle this situation in WPF ?

This you can do it in many ways. Basic thing is place each functionality in different user control, so that you can chose to load them at the run time
Have different user controls and hide all except the first one, depending on the users selections you show the on you want or
Use Content Presenter, depending the user selection load the controls at run time in to the content presenter.

Related

Update user control on Main Window from Page in another solution

Ok, I'm being really thick here and am having a few minor issues which are turning into major ones in my head:
I have a MainWindow that houses a tab control into which I have several "apps" sitting which all have their own solutions. I have built a neat "loading" control which is housed in the main window but is hidden and is only displayed when one of the displayed pages has a button clicked. However, I don't seem to be able to access the user control from the page.
As an example, I have an admin page which controls users in a database which wotks fine. When I click on the submit button I want to make the user control visible on the MainWindow and when the function is finished to hide the control. I know how to unhide and hide the control just not how to access it. I have attached a representation of the file structure below so you can see the issue I have accessing the MainWindow in the main solution from say the pageAdmin.xaml.
I have been googalizing this for a while and can't seem to find a solution that works. Can anyone point me in the right direction? I am open to any suggestions about how to handle this.
Andy
Just to be sure: what do you mean with "apps"? Do you have one WPF application which hosts different components?
Maybe PRISM (Microsoft Framework) is interesting for you. In PRISM you can dynamically load components from different dlls and host them in one WPF application. It has a build in messaging framwork which works very well and the diffetent dlls don't need any references among themselves.

wpf application which shows all forms in one window

hi I want to make a wpf c# application which shows every form(Ex:- user registration, reports , etc..)in one window in other words I want to make an application which have one window and every user control appears and closed there when I want just like games in some games like middle of honor warfighter they have one window and if we chose option option buttons appear in the same window and if we chose graphics that graphic page content appear in that same window.
and I want to know is there any frame work or special method is there which I should fallow other than putting wpf controls one over another and changing there visibility and isopen status.If there is any examples please give me a link
You can use ContentControl for holding any element. also PRISM is best approach.
You can use WPF Popup forms below are some links for more info:-
http://www.dzone.com/articles/understanding-wpf-popups
http://www.c-sharpcorner.com/Blogs/11700/
Take a look at this MDI Control. It helps you to show any kind of usercontrol in one container as window.

User control in avalon dock and separate window

I'm developing a bunch of user controls which do different things - like a maintenance screen, enquiry screen, report screen that sort of thing. Each screen has a dedicated purpose and a single user control holds all the functionality for the one screen.
I'm using avalondock and can place these user controls into LayoutDocuments. This creates a separate tab for each screen/user control. I've got a menu system setup so users can choose which screens they need access to. For each new screen I create a new LayoutDocument, add the appropriate control to it, then add the LayoutDocument to the Docking panel's children.
This is all working fine.
Avalon dock also has the feature of being able to drag out the layout document and make it float - you can also dock it somewhere else in the app if you wish.
I'd like to take this concept one step further: Being able to say right click on a layout document and choose "Make external window" (i'll work out the exact wording later). The effect of this action would be to create a new application with it's own icon in the task bar; being able to alt-tab between it and other apps;
Kind of like when you're in say Excel editing a document and you then open up a second instance of excel. In Windows 7 you get two excel icons in the task bar (one behind the other), and you can alt-tab between them.
This is nearly the behaviour that i'm after. However the second app isn't a full blown copy of the first; it has only the one user control that the user selected.
This is where i'm stuck and would like a bit of guidance.
I'm thinking that i'll probably need some kind of shell app where I can pass in the user control that I want. The shell would act as a window with title, X, minimising etc; the user control would then be the sole content of that shell. Use process.start to create new process and launch ?
Ideally i'd be able to pass in the same control in the same state as the user is currently viewing - so if for example they are part way through editing some customer record in a maintenance screen, then choose the "external window" option, that same customer record would appear in the new window.
Has anyone done something similar or offer advice if i'm on the right track ?
I think I know how to create a shell app but not sure on passing a user control to it dynamically. I'd like to avoid creating different shell apps for each user control.
No need to start a new process for that scenario.
Just create a new Window add your UserControl at runtime and remove the UserControl from the DockingManager. Make sure the Window has ShowInTaskbar set if you want it to show up there.
To get the command to undock the UserControl as a seperate Window you just have to restyle the ContextMenu to incorporate your command (take a look at the VS2010 theme and how the ContextMenu is styled there VS2010 theme.xaml).

Hiding and showing tab bar in WinForms

I'm looking to create a setup form for my application - and I wanted to use a tab form to keep my logic on the one form since it's very simple rather than many of them. Is there a way to remove the tab navigation UI up top and allow me to only progress it programatically?
Look at user controls. They cover pretty much what you want.
Just create a user control for each view. It only consists of the controls you want to have on each tab page anyway. Then you can hide/show the user control you want and you do not have a full blown form for each view.
Look at this tutorial: http://msdn.microsoft.com/en-us/library/a6h7e207%28v=vs.71%29.aspx

Creating "subforms" in WPF?

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.

Categories