2017-10-05 55 views
0

我想为我的wpf应用程序创建一个响应式设计,但有问题。因为当我调整它it.it不工作。任何人都可以帮助我。WpF应用程序的响应UI

试图根据不同的尺寸调整屏幕以查看是否有任何组件对此作出反应。不幸的是,他们不知道我缺少什么

<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

重复的问题,你需要避免在硬编码WPF高度和宽度值..用最大高度,MaxWidth和比例大小。 – Redouane

回答