We currently have a basic implementation of configurable UI, but we feel like it's not the best way. We are developing another application that needs to be configurable from external file and we were wondering if there is a better way to do it.
We currently have xml file with elements with the name and availability which is directly translated to visibility. When the element is available="false" we hide the element with visibility="collapsed". Elements are enclosed in a Setup element with name. There is separate configuration file with setup name that we want to load.
<Setup name="All">
<Element name="toolBarDrawingTools" available="true"/>
...
</setup>
<Setup name="Operator">
<Element name="toolBarDrawingTools" available="false"/>
...
</setup>
It works reasonably well, but we feel like it's not a great approach just to hide elements. A better approach might be to create and add only elements that we need. Layout should not be much of a problem because most element would be ToolBars, MenuItems or UserControls that would be added to StackPanels. So there is no complicated element positioning. What we also found is define xml files with XAML code and at run-time convert it to visual elements. We do not need that much complexity. We have a set of UserControls that we want to dynamically add.
We do not have a clear vision what we want. In the end, we could use our current approach and it would work. What we need is to define what elements will be in final window from external source without the need to recompile whole application.
So what I am asking is what options do we have, are there any "standardized" ways or frameworks. Do you know any articles or books on this topic? Or should we stick with the simplest approach and just hide what we don't want?
Thank you
As I can understand you are after a modular application development. So I can suggest you to look at the next topics; Modular Application Development Using Prism in internet. For example, by this approach you can use the PRISM discovery mechanism(which uses the app.config file to define modules) in oreder to build whole user interface. Here are a couple of possible links:
Building an Extensible Application with MEF, WPF, and MVVM.
Modular Application Development Using Prism Library 5.0 for WPF.
A MEF explanation topic.
Let me know in case you will need more explanations.
Best regards.
Related
I'm working on an XNA project, for the Xbox 360.
For this I have built an extensive UI library, all with relative positions, dozens of controls and stuff like that.
At the moment of speaking, all the design elements are created in page classes, which is a lot of code (think of margins, aligns, labels, and so on).
So I was thinking, shouldn't it be possible, to create a file, like a XAML file for example, and using C#, parse it to objects?
XNAML uses this kind of approach (I think), so I know it must be possible, I'm just wondering how. I could go with the approach of parsing the file manually line by line, and creating every object, but I think this would be pretty complex & nasty code, considering the amount of different objects. Any input is greatly appreciated!
F.Y.I., XNAML is deprecated (I even think it never went live)
I am beginning preliminary design for a general purpose application to be used in my organization. The program needs to be both generic and specialized at the same time. It will contain widgets that are common to all workflows and unique widgets (or input constraints) for individual workflows. To avoid having 97 different one-offs we're planning on building a set of schemas for each workflow. At run-time the user will select their schema from the server and the GUI will throw up the right widgets for their workflow.
This is a C# application that will run in .Net and possibly Mono. That means we are looking into GTK#, in addition to XAML and MonoMac.
We've considered writing XSLT's for our target GUI toolkit. For example:
A Glade XSLT to convert our XSD's to libglade XML.
A XAML XSLT to convert our XSD's to XAML.
A generic XML format for other toolkits that do not support a declarative syntax for GUI's.
A library of classes to read the XSD's directly and generate the GUI.
So, my question is, does this already exist? Is there some workflow toolkit out there for GTK# and libglade or WPF and XAML.
Look at System.Windows.DataTemplate which can be used automaticly by WPF (see property DataType). I think you can extract all UI blocks, which will be used to generate UI and then implement ViewModels and appropriate DataTemplates. And result UI will be composite view model of this blocks.
I did the same thing using XML. What I'm doing is writing down the property set of each controls into a XML file and then reading from it later and regenerating the window.
Some problems I met while doing so
But I was able to complete it. Anyway I guess WPF is better. But if you want an idea I guess I just gave you. (Might not be the best idea though)
Good Luck
Is there an easy way (or perhaps a third-party implementation) to programmatically create a MessageBox with various types of controls on it? Ideally, with some sort of scripting language (ie. XML).
I would prefer not to code this myself from scratch.
There are two ways to do this. One is called WinForms, the other WPF. The latter even uses an XML language (called XAML). Since you didn’t specify what kinds of controls you need, this is the best answer I can offer to your question because it covers the widest available range of controls.
Could you not create a form and customise it as a compromise?
I had a similar question.
Custom MessageBoxes are much simpler to create than what I thought.
How to create a custom MessageBox
The question is pretty simple actually. I have a module in my system containing classes that describe some measurement results. I also have a module containing classes used for a visualization. These two modules are not really related to each other and I prefer to not let them know each other.
Now I want to visualize the results using my visualization. I have to convert the results to a form that the visualization accepts. Where do I put this functionality? In the results module, in the visualization module or in a separate module?
I feel that making a separate module would force me to make a whole lot of separate modules for all combinations of things to visualize and visualizations. But I also don't like to link the two original modules together...
Is there some common practice for this?
Additional info: I use C#
PS: I found it difficult to search for an answer to this because I wouldn't know what the title would be. I also feel that someone who has the same problem will probably not find this question. So if any of you know a better title for this question, don't hesitate to change the title.
A common set of data structures in a separate assembly (and used by various modules) is good practice.
Alternatively, if you really do not want that, you will have to ensure your input types for the visualisation part is a simple data structure, like an array of numbers, and maybe an additional argument which could be a name or something that describes them.
In most cases that won't suffice, so a common assembly is the best way forward IMO.
Is there a pattern where in WPF, I can build a simple UI form from an XML like definition file pulled from a database?
It would allow the user to enter data into this form, and submit it back. The data would be sent back in an XML structure that would closely/exactly mimic the UI definition.
The definition should include the data-type, and if it was a required value or not. I would then like to map these data-types and required values to Data Validation Rules, so the form could not be submitted unless it passes the check.
It should also handle the ability to have lists of repeating data.
I am in the planning stages of this project and have fairly good flexibility in the design at this point, though I am pretty sure I need to stick to the desktop, not web since I may be doing some Office Inter-op stuff as well.
What technology stack would you recommend? I think XMAL and WPF may be close to the answer.
I have also looked at XUL, but it doesn't seem ready or useful for C#. (Found this article from MSDN in 2002)
Thank you,
Keith
Model View Presenter seems to suit WPF quite well, if you've not heard of it before check out the Supervisor Controller pattern, which is a subset of MVP (the author has renamed it to Supervisor Controller and Passive View as two different flavours of MVP). It is a design principal that will help you promote the separation of concerns and works much better than MVC when you don't have a framework to physically enforce it.
You could always try to create a view engine for ASP.NET MVC that works with WPF though, that would be nice.
Well if you wanted to roll something yourself, you can load and render dynamic XAML pretty easily. Rather than have users create XAML directly you could have a subset of it "mapped" to an XML format of your choosing that you XSL into valid XAML:
XmlReader tXml = XmlReader.Create(myXamlString);
UIElement MyElement = (UIElement)XamlReader.Load(tXml);
What about Caliburn?
You might want to consider taking a look at the CSLA.NET framework. You can read about it here along with info on a well written book that's available:
http://www.lhotka.net/Default.aspx
-Eric