Viewbox 强制窗口到屏幕高度

问题描述

所以我有一个 ViewBox 可以在调整窗口大小时缩放 Grid 但是当显示窗口时它已最大化到我的屏幕高度,宽度也比它应该的要大.使用 Width="301" Height="287" 将窗口设置为 301*87,但由于某种原因被忽略。设置 ViewBox 的宽度/高度会更正起始窗口大小,但会阻止它在调整大小时缩放 Grid 的内容。如何让 ShowDialog() 上的窗口大小从 301*287 开始,同时保持 ViewBox 正常工作?

<Window x:Class="Test.Dialogs.DatatypesDialog"
        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:local="clr-namespace:Test.Dialogs"
        mc:Ignorable="d"
        Title="DatatypesDialog" Width="301" Height="287" Background="Black" SizeToContent="WidthAndHeight" MinWidth="301" MinHeight="287" WindowStartupLocation="CenterOwner">
    <Viewbox >
        <Grid Width="285" Height="248" >
        <ListBox x:Name="lbDTypes" Margin="10,10,0" SelectionMode="Single" HorizontalAlignment="Left" Width="140" Height="228" VerticalAlignment="Top"/>
        <TextBox x:Name="tbType" Margin="155,0" TextWrapping="Wrap" Text="" HorizontalAlignment="Left" Width="120" Height="23" VerticalAlignment="Top"/>
        <Button Content="New" Click="NewDType"  Margin="155,38,0" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120"/>
        <Button Content="Move Up" HorizontalAlignment="Left" Margin="155,128,0" VerticalAlignment="Top" Width="120"/>
        <Button Content="Move Down" HorizontalAlignment="Left" Margin="155,153,0" VerticalAlignment="Top" Width="120"/>
        <Button Content="Remove" HorizontalAlignment="Left" Margin="155,88,0" VerticalAlignment="Top" Width="120"/>
        <Button Content="Modify" Margin="155,63,0" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120"/>
        <Separator HorizontalAlignment="Left" Height="20" Margin="155,108,0" VerticalAlignment="Top" Width="120"/>
        <Separator HorizontalAlignment="Left" Height="20" Margin="155,173,0" VerticalAlignment="Top" Width="120"/>
        <Button Content="Save" HorizontalAlignment="Left" Margin="155,193,0" VerticalAlignment="Top" Width="120" RenderTransformOrigin="0.583,-0.025"/>
        <Button Content="Close" HorizontalAlignment="Left" Margin="155,218,0" VerticalAlignment="Top" Width="120"/>

        </Grid>
    </Viewbox>
</Window>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...