This question already has answers here:
Window vs Page vs UserControl for WPF navigation?
(5 answers)
Closed 8 years ago.
I wondered if someone could help me. I'm new to WPF and am currently writing a desktop application, but I cannot seem to get my head around what to use when redirecting someone to a new section of the application.
My options appear to be
Window
Page
UserControl
but I don't understand what the difference between them is, and when I should use each one.
Could someone explain the differences for me, and give an example of what situations/applications you may use each one for?
I'm not sure there is a right answer here, but let me try and guide you. The Window class was created to allow you to have a true window. So, if you need to open a dialog, put it in a Window. Generally you will have at least one Window to house the main form.
A Page was built to be used with the NavigationWindow class. This allows you to build Page classes that are marked up like everything else, but just navigate to them under the covers. This is good if you have a single-paged application where the users just go back and forth between pages (i.e. a wizard).
A UserControl is a way to house reusable markup. These can be housed inside of any ContentControl. These can be swapped out of a "content pane" for example on the main window, like Outlook.
Using that, I hope it helps guide you in the right direction on when to use which. They each have their own uses and are not necessarily exclusive.
Related
A follow up to my Previous Question on adding a button to the Window Chrome (also known as the Non Client Area) in Windows Forms, I have decided to switch to WPF to have a better chance of solving my issue. I need to add some buttons to the Non Client Area or Window Chrome similar to that of Firefox 4
From what I have heard it is easier to do this in WPF. I have no idea where to start. If possible could someone give me some guidance on how to do this?
You should modify the Window Control Template. See examples here.
This question already has answers here:
How to create an Explorer-like folder browser control?
(3 answers)
Closed 5 years ago.
Not sure if this is off topic or not, if it is i will gladly delete.
I am converting one of my companies utility programs to C#.NET in winforms it is written in vb6, DEFINITELY NOT .NET as it is 15 years old. and in the UI it has a tool which looks like this
it acts like a folder browser put stays on the UI unlike a folder browser dialog which is a popup. is there a .NET tool which does the same thing or do i have to use a folder browser dialog. ideally i would like to keep it on the screen because i think it looks better to keep it on the screen rather than a separate box. if anyone knows if this is actually a tool in C#.NET winforms or not that would be great
Yes these controls are no longer avaiable in .net, you can create one yourself relatively easily, here is a MSDN link describing what you want
https://msdn.microsoft.com/en-us/library/ms171645(v=vs.110).aspx
This question already has answers here:
Hiding and Showing TabPages in tabControl
(21 answers)
Closed 6 years ago.
I'm programming a windows application program, using winforms c#
I have a tab control that contains so many pages I need to hide some of these tabs from non-admin users,
for example
if user is an admin no pages will be hided, else page number 1 and 2 will be hided and other pages will be shown,
I don't want to remove pages, just hide because in the program I made you can sign out without closing the program and sign in again as an admin
Please have a look at this thread.
As amazedsaint said:
Visiblity property has not been implemented on the Tabpages, and there is no Insert method also.
You need to manually insert and remove tab pages.
Here is a work around for the same.
http://www.dotnetspider.com/resources/18344-Hiding-Showing-Tabpages-Tabcontrol.aspx
No way to hide it ,you will have to remove pages an re add them for admin user
tabControl.TabPages.Remove(tabPage);
tabControl.TabPages.Add(tabPage);
As seen here you can however disable/enable tabs. While this won't make then invisible, you can restrict access. That should get you going in a workable direction.
I'd personally also put all the restricted tabs at the end, but that's just a point of personal taste.
This question already has answers here:
From Windows Forms to WPF [closed]
(3 answers)
Closed 8 years ago.
I have a large, dated looking windows form project. I want to rework it in my spare time, one form at a time, with beautiful wpf. Is this even possible?
I'm thinking I would have to create a separate project, compile it as a library, add a reference to it in the first project, and call the new window vs the old window?
Or would I have to make windows with hosted elements?
Perhaps the most practical approach is to simple redo the whole thing in one go?
Yes, you could do this. As you say, you could host the WPF elements in Windows forms, allowing you to change one page at a time.
You could also do it the other way, creating a WPF project and hosting the windows forms elements. The good part of that is that you have a normal WPF app when you are done (at the cost of some "startup time" to host the forms stuff).
If you can't release it piecemeal, I would just re write the whole thing, as "One page at a time" doesn't give you any benefit. If you can, your approach seems reasonable.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am developing a WPF Application for a Shop.
So i have a MainWindow and all the rest will be Child.
Which is the best thing to Use as Child Window.
Window
UserControl
Window will be normal, it will be top on the MainWindow and if its UserControl it will be in a Canvas of a MainWindow.
So can anyone suggest me which is best to use out of this two.
I would recommend using UserControls for your child windows. This allows you to set up all of the "parent" controls on your main window and the children won't override them.
As a further suggestion, I would recommend looking into Caliburn Micro. That is a great framework for dealing with WPF windows and user controls.
To add a child UserControl to the parent window, I usually just add a ContentControl to my main form like so:
<ContentControl x:Name="ViewWindow" Margin="10" />
Just assign your child to that control and you will be fine.
I suggest to use a MDI framework like AvalonDock: http://avalondock.codeplex.com/
You will save a lot of time.
Please refer the website : http://wpfmdi.codeplex.com/
Like many things in life & coding: it depends :)
Window
When the new window has its own state & behavior
When there is little to no interaction/messaging between the main window & the pop-up window
User Control
When the state of the underlying main window is critical for the operation of the pop-up
When state changes need to be passed between the 2 windows
These are some of the design decisions which come to mind...
Consider to check MDIContainer. A similar project than MDI for WPF, but it gives you more freedom, since it does not force you to implement MDIChild window, interface or anything.
Child windows will be great for a desktop application when you are decided to use a parent - child window interaction, although I personally suggest you to use a frame in your main windows and use it to host multiple pages.
To learn more about navigation in WPF and silverlight you can visit this link
Using this approach will help you achieve the following advantages:
Lesser chance of memory leaks due to unattached event handlers.
Consistent design could be achieve without indicating style for child windows because you could set page backgrounds to transparent.
Users wont have a hard time locating which window has the focus when other programs were simultaneously used with the software you are building.
I also think that there are also allot of stuff you could consider in building this software but in the end of the day you are still the one who should decide on this matter.
This is only my suggestion and hope this helps :) .