I have a XAML app (specifically a Windows 8 XAML app) that I want to add a night-reading mode for. This will be a setting a user can switch, and it will change the theme colors to be white on black, instead of my standard black on white.
My question is, how can I do this? I'd like to do it actively (meaning, the moment the user switches, I show the new version, and not have to make them restart them app).
I'm still fairly new to XAML, so I don't know if I'm overlooking something. Currently, I'm routing all my styles to go through staticresources in my themes file.
Thanks!
What you're looking for is a theme. Basically it's a set of globally available resources that you can swap out as a set. See here for an example.
Edit: I guess you can't change it without restarting: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/f91a11d6-6e56-4978-8acd-21ae9f3c3a6e/
Related
I want to change the background color for the whole application. I have been searching but I found nothing. Of course there's a way instead of changing the background color for each page right? Hope to get an answer soon. Thanks in advance.
You can look into Xamarin.Forms Shell where the Shell is the container of the entire application. This would enable you to have the background defined at only one area instead of every page. Furthermore, it would allow you to customize it for specific pages if need be.
You can find their example application using a Shell called "Xanimals" here.
I'm creating a windows 8 universal app using C# in Visual Studio 2015. I followed this path to create an empty project: Visual C#->Windows->Windows 8->Universal->Blank App(Universal Windows 8.1).
I'm surprised to find out that the empty app start with black background and white foreground. Is there any particular reason why Microsoft does this?
Also, is there any elegant way to change the background and foreground color? I was able to do it by changing the following config in the MainPage.xaml file:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"></Grid>
To:
<Grid Background="White"></Grid>
But I wasn't able to change the foreground, and if I add a button to the window, the button text cannot be seen on a white background because the button foreground is white. (As far as I know, all the children components will inherit the background color or the foreground color depending all what kind of components they are.)
Any clarification is appreciated.
See the Remarks on the Application.RequestedTheme property on MSDN:
There are two built in themes: "Light" and "Dark". By default your app
runs using the "Dark" theme (in the themeresources.xaml file, the key
name for the "Dark" resources is "Default"). You can set the app's
RequestedTheme property to specify which theme is used.
So setting
<Application ... RequestedTheme="Light">
in your App.xaml makes your application use the Light theme.
Let me explain put it in just a few simplest lines.
I made a new C#/WPF application project in VS 2013 ultimate (x64).
On MainWindow I insert (for example) a button at bottom-right, actually anywhere..
See image below, but the position of the buttons at runtime does not match what it looks like when I am designing
As you can see from the marked up spots in the 2 images, the controls are mispositioned.
I tried to change some XAML attributes, setting min/max sizes, and so on and on. I am running a fresh-install Windows 7 Ultimate (x64) OS, with "Windows 7" aero theme.
I played around MainWindow/Grid properties (tried almost every one), also when I loaded up some custom theme (for example: Expression Dark) issue persists.
Don't get excited so much. Have some control on your temper.
It seems that you have not set the Right Margin of the button you have circled Red in the above image. Try to set the appropriate margins from the Property Window of the corresponding button and see what happens!
I have a ListView control with OwnerDraw = true.
Sometimes my control might not be focused, but have the items selected. Which color should I use to render the selection bar?
I couldn't find any guidelines for that, however, it seems that the ordinary ListView uses the SystemColors.Control color for that (see the picture).
Could I rely on that or would that be incorrect for some cases?
SystemColors.Control is the correct color to use. Unfortunately there is not a predefined Color in SystemColors for an inactive item that makes it obvious, but it is reliable.
The only time you cannot rely on SystemColors is when a user makes explicit changes to the theme color settings in Windows. However, you should not care about that because its an explicit user choice, and you should not interfere with user choices.
As for guidelines, the Windows UX Guidelines do not explicitly state the appropriate color to use for inactive items, but it does stress choosing colors consistant with the operating system that provide good contrast and easy readability.
In applications that I'm not too worried about the look and feel for, I use default system colors, but if I am theming my own application (eg. to look like Visual Studio for example), I avoid system colors altogether and use web colors instead.
Hope this helped.
how do i make sure that the application iam developing will look the same on other windows-systems?
iam developing now on a windows7, with .net 3.5 framework .. (VS 2008)
as an example, i have a toolbar, that i changed its rendermode to system, it looks ok on my windows7, but when i run the application on windows xp, it is different, even the onmouseover backcolor is different. ..
is there a way to make the application looks like on every windows system (talking abt xp, vista and windows 7 only), lets say like exporting the settings of all the controls with the application !? or any trick to make sure it will be always the same ?
thankss in advance
Unless you render the window yourself you're going to always have slight differences between OS'es, they all have different ways of rendering your primitive controls like text boxes, panels, etc.
Also under windows the background color of a window/control is actually (by default) tied into the theme set in windows.
So allowing people to use their own themes is a plus. You really shouldn't force a style on people unless you're theming your own application.
You would have to you get a grab on all of the colours, fonts, transperancy, etc. and use them to override every controls' Paint event/method so that they may use your values.
The only way I see fit would be by writing yourself custom controls while handling these controls appearance throught the Paint() method so that the control may use what you give it. The pain!...
As SLaks commented, you shouldn't care about such details and let the defaut user preferences take over on the native OS, because some surprises may be encountered over time as if Windows doesn't find the font, for instance, it will replace it with its default, which could lead to horrible results. That is just one example. Need others?