Universal app does not allow to remove or disable the close button it seems. We can hide it by going full screen. But when moving cursor over it, brings title bar back. Is there any way to remove the close button?
Reason : I am working on screen time. After allowed time gets over, I want to block the screen. I should remove close button so that user cant get over my app.
Edit : Removing close button wont help completely. It is a part of work. I am just asking how to remove it.
In Windows 10 version 1703 (build 10.0.15063) and beyond, you can prevent the app from closing, using the SystemNavigationManagerPreview class.
Add this to your app manifest:
<Capabilities>
<rescap:Capability Name="confirmAppClose" />
</Capabilities
You need to have the rescap namespace at the Package element:
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
In the constructor of your main form, add:
var sysNavMgr = SystemNavigationManagerPreview.GetForCurrentView();
sysNavMgr.CloseRequested += OnCloseRequested;
OnCloseRequested can be implemented as follows:
private void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
{
var deferral = e.GetDeferral();
e.Handled = true;
deferral.Complete();
}
With current released API, we are able to customize the color of these three buttons in title bar. But there is no property or method could be used to disable or remove these buttons.
In UWP, we can use ApplicationView.TitleBar | titleBar property to get the title bar like following:
ApplicationViewTitleBar titleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;
This property's type is ApplicationViewTitleBar. It only has several properties that can customize the button's color like:
titleBar.ButtonBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonHoverBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonHoverForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonInactiveForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonPressedBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonPressedForegroundColor = Windows.UI.Colors.White;
Using these properties may make the close button invisible like:
However this won't actually hide these buttons. Users can still minimize or maximize the app and when the pointer is over the top right corner, they will still see the close button.
From Windows 8.1, if we want users to use only an application and do nothing else including closing the application, we can use Kiosk Mode. For more info, please see Enable Kiosk Mode in Windows 8.1 and Set up a kiosk on Windows 10 Pro, Enterprise, or Education. However this won't meet your requirement as you want to block the screen after allowed time gets over.
So UWP may not be the best choice for your requirement. You may try to implement it with classic desktop apps.
in App.Xaml.cs add this code :
// Collapse Title bar
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
Window.Current.SetTitleBar(null);
ApplicationView view = ApplicationView.GetForCurrentView();
view.TryEnterFullScreenMode();
C++ Version
// COLLAPSE THE TITLE BAR
Windows::ApplicationModel::Core::CoreApplication::GetCurrentView()->TitleBar->ExtendViewIntoTitleBar = true;
Window::Current->SetTitleBar(nullptr);
Windows::UI::ViewManagement::ApplicationView^ view = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
view->TryEnterFullScreenMode();
Related
I have an old legacy system that uses Winforms and is published with the built in One click,
I look after 3 different installs and each one has its own database it connects to, so its been set up that when a different system is click, it check isCompany1 and will set the Favicon accordingly
so when depoyment is done in the application window the Icon and Manifest is set to the correct ICO, when installed the .exe icon will be what is set there,
However i am trying to bring these all inline as when we debug a drop asks which database we would like to connect to, and depending on that it will set things up differently.
When running in VS the icons in the taskbar will change accoring to the dynamic Favicon however when its depolyed with this new selection it wont change, (it will change once on first load, then wont again)
The issue is some users need access to the different instances so would like different icons at the bottom, but its not changing the task menu, but everything else such as ALT-TAB and the control panel icon is changing,
all forms link into a baseform and call this :
if (App.IsCompany1)
{
this.Icon = new Icon("Resources\\Company1.ico");
}
else if (App.Company2)
{
this.Icon = new Icon("Resources\\Company2.ico");
}
else if (App.Company3)
{
this.Icon = new Icon("Resources\\Company3.ico");
}
AS i said this will change everything but not the Taskbar, but will from VS debugging,
I have made sure the .ico has all sizes, by writing their sizes on each one, and they display correctly the Taskbar and ALT-TAB both use 32x32
If it's any consolation, I couldn't reproduce your complaint.
I put 3 icons in resources, a single button on a form, this code:
private int iconum = 0;
private Icon[] icons = new[] { Properties.Resources.icon1, Properties.Resources.icon2, Properties.Resources.icon3 };
private void button1_Click(object sender, EventArgs e)
{
this.Icon = icons[iconum++ % icons.Length];
}
And it cycled through the icons in the main form title bar and the windows task bar over and over on every button click (made sure to run a release built exe too, not a debug start):
Note: the thing in the top right is my taskbar
I am facing an unexpected behavior of Keyboard showing and hiding in UWP app working on tablet with windows 10.
After carefully testing again and again i noticed that this issue comes when you have focus on input box and keyboard is opened for it. Now focusing next input needs layout adjustment so that it should not be hidden by keyboard. When you try to focus next element, by default previously opened keyboard hides and now i'm not able to open keyboard un till this new input box lose focus and manually gain focus again.
So for controlling this issue i want to prevent automatic hide and show of keyboard every time i switch focus to new textbox. It should open keyboard once the page load (already found solution using InputPane) and hiding should only be by clicking cancel (x) button.
Please check this video for clearly understanding the issue.
https://www.dropbox.com/s/1c876uwytywio1t/Soft%20Keyboard%20Issue.mp4?dl=0
Please vote this suggestion if anyone else is also facing this issue.
https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/34170142-inputpane-does-not-open-when-focus-is-shifted-to-n
This issue has been partially resolved in windows 10 version 1803 released on 30th April, 2018. In this version InputPane does not hide and show again and again when focus is shifted from one input element to other.
You may try to put a horizontal-stretched placeholder control (let say, StackPanel) at the bottom of your page, then let it the same size the on-screen keyboard does. That could prevent uncontrolled auto-hide trigger being fired (at least I did that trick on UWP mobile app):
// on the window initialization, remember the input pane
this._inputPane = InputPane.GetForCurrentView()
// then, subscribe to the events
_inputPane.Showing = (sender, args) =>
{
args.EnsuredFocusedElementInView = true; // skip default vertical-shift behavior
this._placeholderPane.Height = args.OccludedRect.Height;
}
_inputPane.Hiding = (sender, args) =>
{
this._placeholderPane.Height = 0;
}
Hope it helps on the Win10 desktop same way as it was on mobile one.
P.S. Yes, initially the placeholder pane is zero-height and collapsed.
How can you remove the titlebar and buttons in a UWP application? And always start in fullscreen. In WPF this is easy but can't find how to remove the buttons in UWP.
Tre below code in App.Xaml.cs (may be in onlaunched)
To remove the title bar.
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
Window.Current.SetTitleBar(null);
To make it full screen (which also removes buttons)
ApplicationView view = ApplicationView.GetForCurrentView();
view.TryEnterFullScreenMode();
Need to import
using Windows.ApplicationModel.Core;
using Windows.UI.ViewManagement;
below you'll see a screen running in Windows Phone 8.1 one 2 devices. Both are claiming to have Viewport Width and Height of 800x480 however as you can see from the image the 635's nav buttons are overlapping the game area.
I have checked various properties in GraphicsDevice.Adapter and GraphicsDevice.Viewport, but they are both the same!
The screen is running within C# UWP Monogame code. I set the PrefferedBackBufferWidth and Height to 480x800.
How can you tell if the nav buttons with take up part of the screen?
I will expand the answer further.
In windows phone 8.1, you have two ApplicationViewBoundsMode enum values.
UseVisible, pages inside application will use only the visible area excluding StatusBar, application bar and Soft navigation buttons.
To make your app use ApplicationViewBoundsMode.UseVisible option, add the following in app.xaml.cs before `Windows.Current.Activate();
#if WINDOWS_PHONE_APP
ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
#endif
UseCoreWindow, lay out the window's content within the region occupied by the core window (that is, including any occluded areas- including soft navigation buttons).
To make your app use ApplicationViewBoundsMode.UseCoreWindow option, add the following in app.xaml.cs before Windows.Current.Activate();
#if WINDOWS_PHONE_APP
ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
#endif
In some cases, developers may want to use UserCoreWindow option to show content under app bar but as a side effect navigation soft buttons will occlude parts of your page to resolve it, follow the next solution.
You can listen for ApplicationView.GetForCurrentView().VisibleBoundsChanged in WindowsPhone and update the margin of your page.
Here is an article written by Joost van on fixing this issue (and a behavior that you can use out of the box)
Quoting the issue explanation from the above link
If the application view bound mode is set to ApplicationViewBoundsMode.UseCoreWindow in App.Xaml.cs the phone reports the whole screen size – not only the part that is normally taken by the status bar on top and the application bar at the bottom, but also the part that is used by the button bar.
And a snippet from his solution where he updates the margin of page
void KeepInViewBehaviorVisibleBoundsChanged(ApplicationView sender, object args)
{
UpdateBottomMargin();
}
private void UpdateBottomMargin()
{
if (WindowHeight > 0.01)
{
var currentMargins = AssociatedObject.Margin;
var newMargin = new Thickness(
currentMargins.Left, currentMargins.Top, currentMargins.Right,
originalBottomMargin +
(WindowHeight - ApplicationView.GetForCurrentView().VisibleBounds.Bottom));
AssociatedObject.Margin = newMargin;
}
}
to hide the navigation bar in your monogame windows phone 8.1 game add the following code in your app.xaml.cs file under InitializePhoneApplication() method
RootFrame = new PhoneApplicationFrame();
//I have set it to RootVisual to hide navigationbar
RootFrame.FullScreen = true;
if (RootVisual != RootFrame)
RootVisual = RootFrame;
I saw method to do this for current control but I need to do it for all app. I have touch scren and when i click on some textbox virtual keyboard from windows 7 shown. I don't need it because i how own keyboard in program.
Please help.
Thanks.
Not sure if you got an answer in the few months the question was online, but this worked for me.
First, you need a reference to Microsoft.Ink.dll.
var handle = new WindowInteropHelper(this).Handle;
TextInputPanel panel = new TextInputPanel(handle);
panel.InPlaceVisibleOnFocus = false;
That first line gets a Handle to the window of your app, and then you just need to create the TextInputPanel object and set it's InPlaceVisibleFocus to false. This will no longer show the TIP icon when a textbox is touched.