I am using Windows Template Studio to create an application with a modifiable theme. Is it possible to add new contents on the settings page? There are 3 themes available currently: light, dark and default. I would like to add another one for example blue. There is an ElementTheme property but I can't modify it since ElementTheme.cs is from metadata.
Windows Template Studio doesn't create an app, it creates the start of an app. What is generated is intended to be a starting point and should be modified as appropriate for your circumstances.
The generated settings page includes the ability to select light or dark theme. Feel free to support either, or neither of these as appropriate. Implementing custom themes should be done in the same way as an app created from a blank template. Just remove anything WTS puts there you don't need or want.
The official UWP docs have some guidance on creating custom themes.
There is also an app in the store to help you create custom themes for your app.
See also, this question about creating custom themes.
There are instructions on further extending the settings page at https://github.com/Microsoft/WindowsTemplateStudio/blob/dev/docs/pages/settings.md
Related
I'm currently trying to find out, if (also legally) I can use the components of Visual Studio in my applications. I don't mean the controls that are delivered to create my application, like a Button.
I mean the PropertyGrid, the Text Editor, etc, that VS also uses internally in the VS application itself.
The PropertyGrid would be especially interesting because the old winforms PropertyGrid can only be used with WindowsFormsHost, but using the old technolgy is also causing troubles when using windows with transparency, etc.
My questions are:
Am I allowed to do it?
Can you please provide me with an example of how to do that?
I am currently working on an enterprise WPF application and I am experiencing some issues with static resources: globally defined styles and converters.
The application works this way:
There is a shared host WPF application that is used as host for components developed by different teams (it's a PRISM application and MEF is used for importing plugins)
Each team can add plugins by creating new dlls, but cannot modify other teams' dlls
No changes can be made to the host application
My team is in charge of few plugins and we need to add more functionalities but we are wondering what is the best way to solve our problem.
In a simple (standard?) WPF application, we would have styles defined in the App.xaml file and all the xaml UserControls or Windows would be able to link to them at design time easily and of course at runtime.
But now, while I managed to get the styles to work during runtime, I cannot have them working at design time and it is causing two major issues:
I cannot see how things would look like in the IDE
When I reference a converter the IDE complains but I have no way to know how wether it will work at runtime or not.
How do I get StaticResources to be imported and, at the same time, work in my IDE?
If not possible, what other strategies can I adopt to overcome these issues?
If I understand you correctly you want to use your "Design" tab in Visual Studio to see style changes and check the look and feel of your WPF application.
If that is the case, I will disappoint you but I haven't met any WPF developer yet using the 'Design' instead of 'XAML' view to make changes etc. in more advanced applications. Unfortunately the "Design" view has many flaws, doesn't display the Views properly, has problem with static resources converter and what is more it is always resource hungry.
The way we are working with WPF applications is building them and inspecting the problems and changes using a Snoop utility to investigate the application, binding errors, style problems, etc. I have never seen a way to use the build in "Design" view without many flaws, hacks and performance issues.
What is more, you should write a fake host application so that you will be able to run your plugins without the need of running the main app (if that is a problem for you)
I have a bunch of control properties (type of control, location, size, etc.) derived as a text file from an old system on a different platform. I thought it would be fairly easy to load these "control descriptions" into a Windows Forms project in VS 2008 and then be able to maintain the new project in VS just as if it had been created manually.
I'm familiar with using VS and C# but it I'm not sure where to start with this.
I searched the web and found a number of articles about creating controls on forms at run time and that is not so hard, given the information I have, but I want the created form to be a permanent part of a Win Forms project, so I need to get what was created at run time into VS, and accessible in the project just as if it had been manually dropped on the designer surface. Is there a way I could create these forms with a program and then "save" them in a form acceptable to VS?
I manually created a windows Form project to try and use as a "template" and identify how VS does it. I have tried to understand the contents and the relationships between the various resource files, but it is a bit too much. There are also warnings that various files are created by VS and should not be amended manually.
I have almost 1000 forms from the old system so the thought of manually having to add each one to VS is pretty non-viable. I could translate the text descriptions into XML if there is a way to feed an XML description of a Form into a VS Forms project...?
Any advice\direction towards this would be greatly appreciated.
VS uses code generation to create controls in Windows Forms. If you look at a form e.g. Form1 that's in your project, it consists of three files, Form1.cs, Form1.designer.cs and Form1.resx. The Form1.designer.cs file contains the construction of the controls in the InitializeComponent method. VS executes this and parses it at design time to give you the design view of the form where you can make modifications. You could write a program to parse your text files and generate C# code for InitializeComponent to get the right effect. There are various options but you probably would want to use the CSharpCodeProvider class.
Another option is to use WPF. Forms are designed in WPF using XAML, which is an XML based format. (By that I mean, an XAML document is also a valid XML document, but the reverse is not true.) If you create a WPF project and add some controls to it then you could take a look at the XAML file to get an idea of the structure.
I am developing a Windows Form Application in Visual Studio 2008 (C#)
And I want to add Style to the items.
I have been investigating a few ideas about it but I have not found an example about how to do it. Is it really possible?
My app looks like:
But I really want to add more style in buttons, textboxs and other items I have:
My boss insists on using Visual Studio 2008.
To do this without purchasing anything else, you could create your own custom button and text box controls, either from scratch or as controls derived from the existing windows forms controls and then overriding OnPaint etc. Take a look at what's been done here:
http://dotnetrix.co.uk/button.htm
You could also investigate third party options.
Or, use WPF if that's a possibility as others have said. I'd push for WPF! If there's an existing WinForms Code base you can always host WPF Elements in WinForms. See:
Walkthrough: Hosting a Windows Presentation Foundation Control in Windows Forms
IF you wana to use Winforms than you have to buy this one for example:
http://devcomponents.com/
You have to bind the new assemblies in your application that is not a lot of work!
But better way do that with WPF
http://wpftutorial.net/DataGrid.html
Hey Guys, I've searched around for this question but couldn't come up with anything.
The Problem:
If a user changes the Color Scheme on their Windows Desktop, it tweaks some functionality in my .net application.
Is there any way for me to FORCE my application to use the Windows Classic Theme, regardless of what the user's theme has been set as?
Thanks!
At startup set this property on the application object.
Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NoneEnabled;
If you are using Visual Studio: when you go to your application project's properties, you will find a checkbox Enable XP Visual Styles. If you disable that, no theming should be applied to your application. I assume this is equivalent to uncommenting the line of code that user nobugz mentioned.
I have done that using DevExpress (http://devexpress.com) controls, they have their own theming engine, and one of the included themes is the Windows Classic one. The themes even style the window borders, so it is a true complete look and feel control.
As to how to do it natively without a third party control, I do not know.
Specifically, look here for the theming engine in the DevExpress control suite: http://devexpress.com/Products/NET/Controls/WinForms/Skins/