在较小的屏幕尺寸上适合尺寸

时间:2016-09-11 13:40:26

标签: c# wpf

我有一个wpf应用程序。当我在台式电脑上启动它时,它看起来很棒。但是当我在一个屏幕尺寸较小的笔记本电脑上启动应用程序时,我的一个窗口无法适应。 它看起来像这样 enter image description here

当我把设定的尺寸放到WidhtAndHeight的内容时,我明白了 enter image description here

这适合我的窗口,但我的两个向下按钮就在窗口的边缘。我想在按钮和窗口边缘之间留出一些额外的空间。 我试过设置

高度=“{Binding SystemParameters.PrimaryScreenHeight}”

Width =“{Binding SystemParameters.PrimaryScreenWidth}”>

高度=“{x:Static SystemParameters.PrimaryScreenHeight}”

Width =“{x:Static SystemParameters.PrimaryScreenWidth}”

但它给我的结果与第二张图片相同。

我的XAML:

<Window x:Class="Zavod.Objekat.ObjekatIzmena"
        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:Zavod.Objekat"
        mc:Ignorable="d"
        Title="sadas" Height="796" Width="1114" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" FontFamily="Verdana" SizeToContent="WidthAndHeight" Background="#FFA38566" Loaded="Window_Loaded">
    <Grid Margin="0,0,4,0">
  <TabControl x:Name="tabControl" HorizontalAlignment="Left" Height="626" VerticalAlignment="Top" Width="1104" Background="#FFA38566">
            <TabItem Header="Општи подаци">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="459"></ColumnDefinition>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Label x:Name="label" Content="Кључ:" HorizontalAlignment="Right" Margin="345,24,0,0" VerticalAlignment="Top"/>
                    <Label x:Name="label_Copy" Content="Повезивање:" HorizontalAlignment="Right" Margin="345,55,0,0" VerticalAlignment="Top"/>
                    <Label x:Name="label_Copy1" Content="Линк за слику 1:" HorizontalAlignment="Right" Margin="345,86,0,0" VerticalAlignment="Top"/>
                    <Label x:Name="label_Copy2" Content="Линк за слику 2:" HorizontalAlignment="Right" Margin="345,117,0,0" VerticalAlignment="Top"/>
                    <Label x:Name="label_Copy3" Content="Линк за слику 3:" HorizontalAlignment="Right" Margin="345,148,0,0" VerticalAlignment="Top"/>
                    <Label x:Name="label_Copy4" Content="Линк за слику 4:" HorizontalAlignment="Right" Margin="345,179,0,0" VerticalAlignment="Top"/>
                    <TextBox x:Name="textBoxKljuc" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="10,27,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="30" IsEnabled="False"/>
                    <TextBox x:Name="textBoxPovezivanje" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="10,58,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="30" IsEnabled="False"/>
                    <TextBox x:Name="textBoxLinkZaSliku1" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="10,89,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="250" Background="#FFECE7B7"/>
                    <TextBox x:Name="textBoxLinkZaSliku2" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="10,120,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="250" Background="#FFECE7B7"/>
                    <TextBox x:Name="textBoxLinkZaSliku3" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="10,151,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="250" Background="#FFECE7B7"/>
                    <TextBox x:Name="textBoxLinkZaSliku4" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="10,181,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="250" Background="#FFECE7B7"/>


                </Grid>
            </TabItem>
 </TabControl>
 <Button x:Name="buttonSnimiObjekat" Content="Измени" HorizontalAlignment="Left" Margin="231,660,0,0" VerticalAlignment="Top" Width="75" Click="buttonSnimiObjekat_Click"/>
        <Button x:Name="buttonOdustani" Content="Откажи" HorizontalAlignment="Left" Margin="816,660,0,0" VerticalAlignment="Top" Width="75" Click="buttonOdustani_Click" />


    </Grid>
</Window>

1 个答案:

答案 0 :(得分:1)

查看应如何创建布局的示例:

send "exit\r"
expect eof
close
wait

您的问题是边距和尺寸不变。当您使用Expression Blend并且不会手动编写XAML时会发生这种情况。