2012-10-19 33 views
1

我在網格內有一個網格。我希望它援用最大尺寸無論窗口大小:改進的表示和標點符號

  • Main_Grid應該是最大寬度
  • Grid_tool_bar應該是最大寬度

,但實際上它是不是和我無法找到原因。這裏是代碼:

<Window x:Class="SocialNetworkingApp.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Background="White" WindowStyle="None" HorizontalAlignment="Stretch" WindowState="Normal" AllowsTransparency="True" WindowStartupLocation="CenterScreen"> 
    <Border Margin="0,0,0,0" BorderBrush="Black" BorderThickness="1,1,1,1" > 
     <Grid x:Name="Main_Grid" Background="White" Width="Auto" Height="Auto" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="30" /> 
       <RowDefinition Height="25"/> 
       <RowDefinition Height="50"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="20"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="1*"/> 
      </Grid.ColumnDefinitions> 
      <Grid Name="Title_Bar" Grid.Row="0" VerticalAlignment="Top" ShowGridLines="True" Grid.IsSharedSizeScope="True" MouseDown="Drag_Window" Background="#FF4FA2DA" HorizontalAlignment="Left" Width="766" Height="31"> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="Auto" /> 
       </Grid.RowDefinitions> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="30"/> 
        <ColumnDefinition Width="Auto"/> 
        <ColumnDefinition Width="120" /> 
       </Grid.ColumnDefinitions> 
      </Grid> 
     </Grid> 
    </Border> 
</Window> 

解決通過最小化屬性

<Window x:Class="SocialNetworkingApp.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Background="White" WindowStyle="None" WindowState="Normal" AllowsTransparency="True" WindowStartupLocation="CenterScreen"> 
    <Border Margin="0,0,0,0" BorderBrush="Black" BorderThickness="1,1,1,1" > 
     <Grid x:Name="Main_Grid" Background="White" > 
      <Grid.RowDefinitions> 
       <RowDefinition Height="10" /> 
       <RowDefinition Height="20"/> 
       <RowDefinition Height="40"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="20"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="1*"/> 
      </Grid.ColumnDefinitions> 
      <Grid Name="Title_Bar" Grid.Row="0" Height="Auto" Background="#FF4FA2DA" > 
       <Grid.RowDefinitions> 
        <RowDefinition Height="Auto" /> 
       </Grid.RowDefinitions> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="30"/> 
        <ColumnDefinition Width="Auto"/> 
        <ColumnDefinition Width="120" /> 
       </Grid.ColumnDefinitions> 
      </Grid> 
     </Grid> 
    </Border> 
</Window> 

回答

0
<Grid Name="Title_Bar" Grid.Row="0" ... Width="766" Height="31"> 

如果你想讓它自動調整,做到不指定的寬度。只要刪除該屬性。

編輯:也刪除HorizontalAlignment="Left"設置者。至少對於外部電網。

+0

我試過這樣,它沒有工作,現在整個子網格縮小到5像素左右 –

+0

請參閱編輯。總是先嚐試最小布局。只添加你真正需要的東西。 –

+0

我刪除了路線,仍然沒有。 –