[英]How to adjust the height of the Mahapps window to minimum height
我想用ShowTitlebar = false將Mahapps窗口的高度調整到最小(比如說5)。 如果我嘗試通過拖動角來調整窗口大小,則只能將其最大調整為36(標題欄高度)。
<Controls:MetroWindow x:Class="TestWPF.MahappsWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="MahappsWindow1" Height="300" Width="300"
UseNoneWindowStyle="True" MinHeight="1" MinWidth="1" ShowTitleBar="False">
<Grid>
</Grid>
我可以使用以下快照高度調整大小: Mahapps屏幕截圖
但是,當WindowStyle設置為none時,可以在Windows和ModernUI中調整窗口高度。
下面的現代ui代碼可以調整為最小高度1。
<mui:ModernWindow x:Class="TestWPF.ModernWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:WpfApplication1="clr-namespace:TestWPF"
mc:Ignorable="d"
Height="400" Width="400" WindowStyle="None"
MinHeight="1" MinWidth="100" IsTitleVisible="False"
Title="ModernWindow" ResizeMode="CanResize"
xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
LogoData="F1 M 24.9015,43.0378L 25.0963,43.4298C 26.1685,49.5853 31.5377,54.2651 38,54.2651C 44.4623,54.2651 49.8315,49.5854 50.9037,43.4299L 51.0985,43.0379C 51.0985,40.7643 52.6921,39.2955 54.9656,39.2955C 56.9428,39.2955 58.1863,41.1792 58.5833,43.0379C 57.6384,52.7654 47.9756,61.75 38,61.75C 28.0244,61.75 18.3616,52.7654 17.4167,43.0378C 17.8137,41.1792 19.0572,39.2954 21.0344,39.2954C 23.3079,39.2954 24.9015,40.7643 24.9015,43.0378 Z M 26.7727,20.5833C 29.8731,20.5833 32.3864,23.0966 32.3864,26.197C 32.3864,29.2973 29.8731,31.8106 26.7727,31.8106C 23.6724,31.8106 21.1591,29.2973 21.1591,26.197C 21.1591,23.0966 23.6724,20.5833 26.7727,20.5833 Z M 49.2273,20.5833C 52.3276,20.5833 54.8409,23.0966 54.8409,26.197C 54.8409,29.2973 52.3276,31.8106 49.2273,31.8106C 46.127,31.8106 43.6136,29.2973 43.6136,26.197C 43.6136,23.0966 46.127,20.5833 49.2273,20.5833 Z" Loaded="ModernWindow_Loaded"
>
<ScrollViewer>
<StackPanel>
</StackPanel>
</ScrollViewer>
我可以使用以下快照高度1調整大小: Modern UI屏幕截圖
有沒有辦法我可以將Mahapps窗口的大小減小到最小高度(小於36)而沒有標題欄。
您需要以%方式划分網格,而不是使用綁定:
Width="{Binding ActualWidth, ElementName=YourElementName, Mode=OneWay}"
Height="{Binding ActualHeight, ElementName=YourElementName, Mode=OneWay}"
這是Mahapps的錯誤。 無法將mahapps窗口的大小調整到超過標題欄的高度。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.