WpF应用程序的响应UI

WpF应用程序的响应UI,wpf,responsive-design,Wpf,Responsive Design,我正在尝试为我的wpf应用程序创建一个响应性设计,但有问题。因为当我调整它的大小时,它不起作用。所以任何人都可以帮助我 尝试根据不同的大小调整屏幕,以查看是否有任何组件对此做出反应。不幸的是他们没有我不确定我错过了什么 <Window x:Class="LSLABAPP.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=

我正在尝试为我的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>

当您设置固定的高度或宽度时,wpf将不会调整大小


但是,当您设置固定的高度或宽度时,wpf将不会调整大小,这可能是一个重复的问题


但这可能是一个重复的问题,您需要避免在WPF中硬编码高度和宽度值。。使用最大高度、最大宽度和比例大小。您需要避免在WPF中硬编码高度和宽度值。。使用最大高度、最大宽度和比例大小。