Black StatusBar with black font in Windows 10 mobile app - c#

I have a Windows 10 UWP app running on mobile. When I run the app in an emulator, everything works fine. When I run it on a device (Lumia 550), the StatusBar is black with black font and the status indicators are not visible.
Is this some kind of bug?
I know I can force the StatusBar to have white background and black color, but the requirement for the app is to stick with the theme (black StatusBar in dark theme, white in Light theme).
If I create a new empty Windows 10 app and run it on a device, the problem is the same, it is not specific to my app.

Edit
Here's a more proper answer:
In Windows 10 Mobile the statusbar inherits it's background color from the topmost page. The foreground color is inherited from RequestedTheme.
This means that if you set the background color of your page to black and your RequestedTheme to Light (which gives a white foreground color), the text will be black on black.
Original post
Have you read this?: https://stenobot.wordpress.com/2015/07/08/uwp-app-development-styling-the-mobile-status-bar/
It might help you.

I have struggled with this a bit.
A strange thing is that when I start my app, the theme (Application.RequestedTheme) is always Light, ignoring the setting on the phone. Even when I try to set it to Dark in the constructor, it immediately reverts to Light. This could explain the black foreground color.
I also experience the inconsistency between simulator and device. To take care of that, I (as suggested in other answer) set the background color of the page (not the root Grid):
<Page
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
... >
</Page>
With this, the status bar at least appear readable.

If you got the black font on the black background with your Light theme project, simple add this line into OnLaunched method in App.xaml.cs:
rootFrame.Background = new SolidColorBrush(Colors.White);

Just add RequestedTheme="Dark"in App.xaml

In your reference Manager add Windows Mobile extensions for the UWP
Then in App.XAML.cs on
protected override void OnLaunched(LaunchActivatedEventArgs e)
add
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
statusBar.BackgroundColor = Windows.UI.Colors.Green;
statusBar.BackgroundOpacity = 1;
statusBar.ForegroundColor = Colors.White;
}
If you want to change Title bar on PC version of UWP app, then you could use this
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
{
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
if (titleBar != null)
{
titleBar.ButtonBackgroundColor = Colors.DarkBlue;
titleBar.ButtonForegroundColor = Colors.White;
titleBar.BackgroundColor = Colors.Blue;
titleBar.ForegroundColor = Colors.White;
}
}

Related

SetWindowDisplayAffinity backcolor image/transparent

how to make transparent black square in SetWindowDisplayAffinity?
put a picture or transparent background instead of a black square
I need the window not to be visible at all in the video capture
I found a solution.
const uint WDA_EXCLUDEFROMCAPTURE = 0x00000011;
SetWindowDisplayAffinity (this.Handle, WDA_EXCLUDEFROMCAPTURE);
I also used it. But it works in Windows 10 version 2004 and above. I tried on new versions of Windows and everything worked out, the window was completely invisible in the screen capture.

SignaturePadView in Xamarin Forms different on ios and android

I have added the Nuget packages for Xamarin.Controls.SignaturePad.Forms into my xamarin forms solution. I call the GetImageStreamAsync(SignatureImageFormat.Jpg);. When I run it with White background and black stroke color it only works on ios. Android displays a black screen. THen when I try to set the background to black and White stroke color, Android displays correctly and ios displays a white block and doesn't display correctly. Does anyone have any solutions to this? Ideally it would be good to have the same background color and stroke color on either platforms. I can get around it by setting the background color and stroke color depending on OS, but that seems a bit hacky. Here's what works with the android in Xamarin Forms when I call var str = await PadView.GetImageStreamAsync(SignatureImageFormat.Jpg);. Setting a "White" Background doesn't show up in Android. It always shows a black square. Is there something I'm missing? I'm trying the source https://github.com/xamarin/SignaturePad Thanks.
<forms:SignaturePadView x:Name="PadView"
HeightRequest="100"
WidthRequest="140"
BackgroundColor="Black"
SignatureLineColor="White"
PromptText="Sign here"
PromptTextColor="Gray"
ClearText="Clear"
ClearTextColor="{StaticResource Accent}"
StrokeColor="White"
StrokeWidth="4" />
see comment - Rebuilt source and hard coded White into android background color when it creates the image of the signature. It suits what I have to do, so may not work if you want another color, or you may have to hard code your own color in the android and ios version. Didn't delve into the SignaturePad code enough to see what was going on.

UWP AppBar color c#

I'm trying myself at designing windows universal apps (windows 10), and in order that everything would look right, I wish to change application border color. I was checking forums earlier and non of the solutions seem right.
Thanks for all your time
Here is an example I have found, mint color even tho I have dark gray as my system color.
From UWP Windows 10 App, TitleBar and Status bar customization:
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
{
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
if (titleBar != null)
{
titleBar.ButtonBackgroundColor = Colors.DarkBlue;
titleBar.ButtonForegroundColor = Colors.White;
titleBar.BackgroundColor = Colors.Blue;
titleBar.ForegroundColor = Colors.White;
}
}

windows phone 8.1 header bar icon colours

My application is setting the Requested theme in the App.xaml as we only want to show a light theme regardless of what the user's system theme is.
Problem is, when the user is on a dark theme (which has white icons for signal/battery/time etc) the app switches all style resources to use light theme but does nothing about the header bar. This creates the situation where you have a white page background and white icons on top of it.
Is there a way to change the theme applied to this top bar?
I tried adding a dark colour behind the bar (30px high rectangle with margin -30 on top) but the behaviour happens on light theme too so then if the user is on light theme, the icons are black and too dark to see on the colour background.
It's not obvious in the picture, but on top of that map there is the header bar with icons but the icons are white and the theme says page background is white.
Turns out the correct answer is:
http://msdn.microsoft.com/library/windows/apps/windows.ui.viewmanagement.statusbar(v=win.10).aspx
This class also cannot be used from the XAML so you have to do:
public MainPage()
{
StatusBar statusBar = StatusBar.GetForCurrentView();
statusBar.ForegroundColor = new Windows.UI.Color() { A = 0xFF, R = 0xFF, G = 0x00, B = 0xAA };
this.InitializeComponent();
}

How to Change the Color of Application Bar Buttons when Pressed

An interesting question, I was wondering if it is possible to theme the application bar buttons in Windows Phone 8 to use another color other than the current accent color as the background of the button when pressed. I am currently creating my app bar in code behind in my test application. Are there any suggestions of how to do this? I have not yet found a resource online anywhere. Essentially what I have right now is a very simple app bar for testing purposes.
MainPage.xaml.cs
private void BuildLocalizedApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
// Create a new button and set the text value to the localized string from AppResources.
ApplicationBarIconButton newButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/new.png", UriKind.Relative));
newButton.Text = "new";
newButton.Click += newButton_Click;
ApplicationBar.Buttons.Add(newButton);
}
If you set the ApplicationBar's Foreground to something like #FFFEFEFE for white and #FF010101 for black the ApplicationBarIconButtons will not use the AccentBrush when they are pressed, they will use the defined Foreground Color of the ApplicationBar!
It took me hours to find the solution to that problem but it makes some sense: Microsoft uses White(#FFFFFFFF) and Black (#00000000) for their dark and light theme. In this case the ApplicationBar uses the AccentBrush and if the Foreground is set to a different color it uses the defined one.
So you just need to add the following line (white):
ApplicationBar.Foreground = new SolidColorBrush(Color.FromArgb(255, 254, 254, 254));

Categories