我正在尝试为我的wpf应用程序创建一个响应式设计但是有问题。因为当我调整它时它没有工作。所以任何人都可以帮助我。
尝试根据不同尺寸调整屏幕,以查看是否有任何组件对此作出反应。不幸的是,他们不知道我错过了什么
<Window x:Class="LSLABAPP.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LSLABAPP"
mc:Ignorable="d"
Title="MainWindow" Height="300" Width="525" MinHeight="300" MinWidth="525" ResizeMode="CanResizeWithGrip">
<Grid>
<Grid.Background>
<ImageBrush/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition MinHeight="80" Height="50"></RowDefinition>
<RowDefinition MinHeight="40" Height="40"></RowDefinition>
<RowDefinition MinHeight="40" Height="40*"></RowDefinition>
<RowDefinition MinHeight="40" Height="40*"></RowDefinition>
<RowDefinition MinHeight="40" Height="40*"></RowDefinition>
<RowDefinition MinHeight="40" Height="40*"></RowDefinition>
<RowDefinition MinHeight="40" Height="40*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="100" Width="100"></ColumnDefinition>
<ColumnDefinition Width="417"/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="UserName" Grid.Column="1" HorizontalAlignment="Left" Height="25" Margin="30,10,0,0" Grid.Row="2" TextWrapping="Wrap" Text="UserName" VerticalAlignment="Top" Width="172"/>
<PasswordBox x:Name="Password" Grid.Column="1" HorizontalAlignment="Left" Margin="30,10,0,0" Grid.Row="3" VerticalAlignment="Top" Width="172" Height="25"/>
<Label x:Name="UsernameLable" Content="UserName" HorizontalAlignment="Left" Margin="10,10,0,0" Grid.Row="2"
Grid.Column="0" VerticalAlignment="Top" Width="81" Height="26"/>
<Label x:Name="PasswordLable" Content="Password" HorizontalAlignment="Left" Margin="10,10,0,0" Grid.Row="3"
Grid.Column="0" VerticalAlignment="Top" Width="81" RenderTransformOrigin="0.333,2.038" Height="26"/>
<Canvas Grid.Column="1" HorizontalAlignment="Left" Height="80" VerticalAlignment="Top" Width="417" Background="#FF4E79EE">
<Label x:Name="label" Content="Testing" Canvas.Left="70" Canvas.Top="10" Width="260" Foreground="White" FontWeight="Bold"/>
<Label x:Name="label1" Content="DEV Environment" Canvas.Left="130" Canvas.Top="36" Foreground="red" FontWeight="Bold"/>
</Canvas>
<Canvas HorizontalAlignment="Left" Height="80" VerticalAlignment="Top" Width="100" Background="#FF4E79EE" />
<Image Margin="0,0,414,0" Grid.ColumnSpan="2">
<Image.Source>
<BitmapImage UriSource="Content/.ng" />
</Image.Source>
</Image>
</Grid>
</Window>
答案 0 :(得分:0)
当您设置固定的高度或宽度时,wpf将不会调整大小。
但这可能是How to make all controls resize accordingly proportionally when window is maximized?
的重复问题