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>
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 am using MahApps.Metro MetroWindow.
I'm assigning my title in the following way:
Title="My Application"
But it is showing the title as "MY APPLICATION".
I have cross verified it by setting the Title to "My", but it shows "MY".
Hope I need to set some property attribute to fix this.
Simply set the TitleCaps property of the window to false
<Controls:MetroWindow x:Class="MahApps.Metro.Simple.Demo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
Title="MainWindow"
Height="200"
Width="600"
TitleCaps="False">
That should be it.
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.
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.
I am needing to make a custom window with WindowStyle.None, AllowsTransparency = true, etc.
and "resizeable"
how con help me to create resizeable this?
tanx...
The most simple solution is to implement the ResizeMode property, setting it to "CanResizeWithGrip".
<Window x:Class="TestProject.ScratchWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Opacity="1.0"
ResizeMode="CanResizeWithGrip"
WindowStyle="None"
AllowsTransparency="True"
Title="Test Window">
<!-- Window Contents Here -->
</Window>