Out of curiousity, is it possible to have 2 application layouts without having to have 2 projects?
Like one layout for desktop/laptops. And then one layout for tablets?
I know winforms only has 1 designer file, and that probably answers my question, but I was curious if i really just needed to re-create a whole new program for a tablet layout, even though it would have all the same functionality as the desktop, with all the same controls, just look slightly different.
I'd put the core functionality in a library assembly (DLL), and write two UI applications that reference the same core assembly.
You can write your own custom LayoutEngine which handles the layout. This way you leave all layout oriented task to your engine and can focus on code.
Here's an article on Microsoft on how to do this (with sample source):
http://msdn.microsoft.com/en-us/library/ms973821.aspx
From the article:
All Windows Forms controls provide a Layout event, along with a host
of other notifications, which enables the writing of a complex layout
code. To facilitate writing reusable layout engines, we can provide a
basic framework.
Related
Here's the situation:
We have an existing .NET executable that contains an application using WPF components (dialogs and forms). This executable was created using Gupta Team Developer 6.1, but I'm not sure that is relevant to my question. We'd like to re-use some of these forms in a C#-application, but this is proving difficult.
When we include the external components, either in XAML or by instantiating them in code, they look OK (i.e. fields, buttons, layout etc.), but the event wiring seems to be missing. Nothing happens when pressing buttons and tables/grids are empty.
I've read previous articles on this site on using external WPF components, but they all mention external assemblies compiled as control libraries. Are we trying to do something that's not really possible?
P.S As an experiment we've tried to instantiate the App-object from the executable directly and this brings up a fully functional version of the entire application (well, duh), but we'd really like to be able to pick and choose from the individual forms/dialogs.
I have a WPF executable and I wish to make provisions to it, so that later,
someone from outside might modify or add another window or page
using dll totally separate from my solution.
For short, I wish to make my wpf windows or pages pluggable. How do I do this?
Prism's support modular, on-demand-loading of modules and other parts of your application, in it's core.
you can use MEF framework to make pluggable modules (windows and pages), as it's fully integrated with Prism.
You can find examples and more information in the following resources:
http://www.codeproject.com/Articles/188054/An-Introduction-to-Managed-Extensibility-Framework
http://www.codeproject.com/Articles/37579/Managed-Extensibility-Framework-Part-2
http://www.codeproject.com/Articles/432069/Simple-MEF-Application-for-Beginners
http://www.codeproject.com/Articles/232868/MEF-Features-with-Examples
I've created a win form application which consist of a single form. We have 8 tabs to access the modules of application.
The problem is we are a team of 4 who works on this project. But since it is a single form application, only one person can use the file at a time. Is there anyother way to build application with more than one file?
Please provide some solution.
Firstly, you should probably have a separate UserControl per tab. That will give you 8 files (at least) since you have 8 tabs.
Secondly, you should be using a Model-View-Controller style architecture for Windows Forms applications. That will give you at least one controller, but likely you will have one controller per UserControl (i.e. per tab). You might even have an overall controller that manages the per-tab controllers.
You might only have one data model for the entire app, or you might have one data model per UserControl (tab).
If you did all that, you'd have a few more source files.
However, it's actually difficult to say without knowing anything about your app.
Try using user controls to make each tab modular.
Figure out what are the parameters that each tab accepts and that it exposes and then create user controls that have that behavior.
Here are couple resources to get you started
http://msdn.microsoft.com/en-us/library/aa302342.aspx
User Control vs. Windows Form
User Controls in Windows Forms - Anything similar to ASP.NET User Controls?
Even if this is a giant ball of wax, your source control tools are shoddy and breaking it up into separate classes is hard to do, you can still take advantage of a Form class being a partial class. Which means that you can spread the code over any number of source code files, not just the two files that the designer creates. So a logical organization is to move code that belongs to a particular tab in its own partial class with the same form class name and its own source code file. Some cut+paste required however when you add event handlers with the designer.
Have you considered using MDI?
MSDN Working with MDI...
Examples are in VB.Net but I'm sure it will be easy to use C# if you really want to - I'm not sure why, but... :)
I would like to know the difference between page, frame, navigation windows in c# wpf
what is the best choice of them for wpf windows application?
in my application how to make fixed part (contain main buttons) and changeable part (show pages) after clicking buttons in fixed part
are there any good websites provides video tutorials for c# wpf from beginning to professional?
thank you
A Page is much like a user control, only that is is displayed within a Frame, which again is part of a NavigationWindow. A NavigationWindow is a special kind of window that allows for page navigation and can display the respective controls for navigating pages.
A paged application is a good choice if you want Wizard-like functionality, or if the user experience should be comparable to what you get when browsing the web. In many cases, using standard WPF windows is a better choice.
The NavigationWindow already contains a "fixed part" that can contain controls. You can also use a normal window, place a Frame in it and then - through proper layout - create your own "fixed parts". Navigation would then come down to calling the navigation methods the Frame provides.
From the answer to this question:
Pages are intended for use in navigation applications (usually with back and forward buttons, e.g. Internet Explorer). Pages must be hosted in a NavigationWindow or a Frame
The best choice depends on what kind of application you want to create. Is it a wizard or navigation type application or just a regular application with one window (maybe with tabs)?
I would definitely consider using a MVVM framework like Caliburn.Micro for making a WPF application. It has some really powerful mechanisms for dealing with Screens, Conductors and Composition, in addition to encouraging you to decouple your application by using the MVVM pattern. The author of Caliburn.Micro, Rob Eisenberg, has written some tutorials with extensive explanation about and how to use the framework under the project's documentation. There is also lots of resources around the interwebz, google it! :)
I can also recommend Pluralsight's WPF and XAML Fundamentals and WPF Advanced Topics, they should cover what whatever is worth knowing about WPF :)
I'm working on a windows forms application that reads and displays source code files from my hard drive. I'm not sure which control would be best suited for this. Is there any library that will allow me to display the source code with colors and numbered code-lines?
EDIT: To clarify, what i'm looking for is a way to display the code with colors and line-numbers, no need for editing. The application is to be used by a teacher, allowing him to view source code files handed in by his students. The teacher doesn't have to be able to edit the files.
ScintillaNet is a WinForms control which is a .NET wrapper of the excellent Scintilla library and is quite good. Avalon which is mentioned in another answer is also very good, but it is an WPF control (of course, WPF controls can be added to WinForms forms by using ElementHost controls, but it will introduce additional complexity which may or may not be warranted).