I've written an installer with a WPF UI. During the installation of a pre-requisite, the full screen WPF ui loses focus and task bar appears for some time. Currently below is how my window element looks.
<Window x:Class="CustomBA.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resources="clr-namespace:KubeCustomBA.Resources"
mc:Ignorable="d"
Title="Installer" Width="1431" MinWidth="400" Height="588.9" MinHeight="300" ResizeMode="NoResize" WindowState="Maximized" ShowInTaskbar="False" Topmost="False" WindowStartupLocation="CenterOwner" WindowStyle="None" Background="#FF222222">
How can I avoid it from losing focus and showing the task bar? Any help would be much appreciated.
Related
Writing a program using WPF (with MahApps) In C# and wondering how can I disable a user being able to right click the TitleBar and brining up the window options menu?
Edit1: to confirm I would like to keep the min/max/close button on the bar, just remove the right click event
There is a new property in MahApps v2.x called ShowSystemMenuOnRightClick.
<mah:MetroWindow x:Class="MetroDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MahApps.Metro - Demo Application"
Width="900"
Height="600"
mah:DialogParticipation.Register="{Binding}"
GlowBrush="{DynamicResource MahApps.Brushes.Accent}"
ShowIconOnTitleBar="True"
ShowSystemMenuOnRightClick="False"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
</mah:MetroWindow>
I have a default grid control defined in xaml:
<Page
x:Class="App.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
</Grid>
</Page>
And this grid does not start from the top of the page as you can see from the picture below:
One way to achieve this is to set a negative margin like this:
<Page
x:Class="App.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Margin="0,-26.667,0,0">
</Grid>
</Page>
So it will look like in this picture:
However, I've watched some of Bob Tabor's videos like this one and all of his default controls starts right from the top of the page.
What is the problem here and how can I solve it without setting a negative margin?
Well status bar is there by default.
You have 2 options:
Hide it -> Hide Status bar in Windows Phone 8.1 Universal Apps
put your content under it:
var applicationView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
applicationView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
You may wish to read this for additional info:
http://blogs.msdn.com/b/amar/archive/2014/05/12/status-bar-in-windows-phone-8-1.aspx
I've just started using MahApps with WPF. After converting my WPF Window to a MetroWindow it's no more locked. With standard WPF and the following settings
WindowStyle="None" ResizeMode="NoResize the window is not movable.
However with MetroWindow it is movable. I don't want users to be able to move the window around. How can I achieve this with MetroWindow?
As #Mathew said, you can set IsWindowDraggable property of your MetroWindow to false. A sample code can be like this:
<controls:MetroWindow
x:Class="MyNameSpace.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
IsWindowDraggable="False"
ResizeMode="NoResize"
WindowStyle="None"
ShowTitleBar="False"
>
.....
</controls:MetroWindow>
I have a WPF application that has the title set to "Pioneer Document Handling Viewer" within the xaml:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mt="clr-namespace:DocumentHandlingTouch" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="DocumentHandlingTouch.MainWindow"
Title="Pioneer Document Handling Viewer" Height="909" Width="1020" WindowState="Maximized"
Icon="default_document.ico" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
But it shows up with an older title: when I run it.
I've tried a clean rebuild. Reopening the project, etc and the title still doesn't change.
Why would the XAML be different than the runtime title?
I have the following WPF window definition but the focus/lost focus events are not firing when I click away from the application, any ideas?
<Window x:Class="BevaClient.windowMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:BevaClient"
xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="VPN Tool" Height="500" Width="370"
Focusable="True"
WindowStyle="None"
ResizeMode="NoResize"
Topmost="True"
Style="{StaticResource defaultWindow}"
Loaded="Window_Loaded"
GotFocus="Window_GotFocus"
LostFocus="Window_LostFocus">
I have tried setting topmost to false to see if this was the issue but it makes no difference.
Any advice on this issue would be very much appreciated.
Thanks,
David
Hook to Activated and Deactivated events instead.