Microsoft Developer Network > 포럼 홈 > Windows Presentation Foundation (WPF) > Grid autosize problem in Window with Expanders!
질문하기질문하기
 

질문Grid autosize problem in Window with Expanders!

  • 2008년 7월 4일 금요일 오전 9:27Mathias Lorenzen 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음

    I am using .NET Framework 3.5 SP1, Silverlight 2 Beta 2, and Expression Blend 2.5 June Preview.

    I am having a problem with a Window that will not size itself to fit the content in height. When I expand an expander, all rows below the row with the expander in, gets moved below the window in the grid, and becomes invisible. Please try the code by yourself, and try to help me figure out why.

    Here's my XAML.

    <Window x:Class="Window7"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Coldflame version 3" Width="410" Background="{x:Null}" WindowStyle="None" Opacity="1" AllowsTransparency="True" ResizeMode="NoResize" Topmost="True" SizeToContent="Height" x:Name="CustomMessageBox" WindowStartupLocation="Manual" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
        <Grid Background="{x:Null}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" ShowGridLines="True" ScrollViewer.VerticalScrollBarVisibility="Visible" ClipToBounds="True">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" MinHeight="56" />
             <RowDefinition Height="Auto" MinHeight="5"/>
             <RowDefinition Height="Auto" MinHeight="5" />
             <RowDefinition Height="*" MinHeight="5" />
                <RowDefinition Height="Auto" MinHeight="43" />
            </Grid.RowDefinitions>
            <Rectangle Stroke="#FFFFFFFF" Margin="0,0,0,0" Grid.Row="0" RadiusX="10" RadiusY="10" Opacity="0.8" x:Name="MainRectangle" Grid.RowSpan="5" Height="Auto" ClipToBounds="True">
          <Rectangle.Fill>
           <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FF1A00FF" Offset="0"/>
            <GradientStop Color="#FF000000" Offset="1"/>
            <GradientStop Color="#FF0C0074" Offset="0.121"/>
            <GradientStop Color="#FF000000" Offset="0.647"/>
           </LinearGradientBrush>
          </Rectangle.Fill>
         </Rectangle>
            <TextBlock Margin="12,12,33.96,0" Height="15.96" VerticalAlignment="Top" Text="Coldflame version 3" Foreground="#FFFFFFFF" ScrollViewer.IsDeferredScrollingEnabled="False" TextWrapping="Wrap" x:Name="MainTitle" Opacity="100" />
            <TextBlock Foreground="White" Margin="12,33.96,12,6" x:Name="MainContent" Opacity="100" ScrollViewer.IsDeferredScrollingEnabled="False" Text="Notification description" TextWrapping="Wrap" />
            <Expander Grid.Row="1" Foreground="White" Header="Notification options" IsExpanded="False" x:Name="NotificationOptions" Margin="12,6,12,6" Style="{DynamicResource Flamefusion_Expander}" Grid.RowSpan="1">
                <Grid Height="Auto" Margin="5">
                    <CheckBox Style="{DynamicResource Flamefusion_CheckBox}" Foreground="White" Height="Auto" HorizontalAlignment="Left" IsChecked="False" Margin="0,0,0,0" VerticalAlignment="Top" Width="Auto" x:Name="CheckBox1" Content="Do not show messages with this title again"/>
                </Grid>
            </Expander>
            <Expander Foreground="White" Header="Technical details" IsExpanded="False" Margin="12,6,12,6" Style="{DynamicResource Flamefusion_Expander}" Grid.Row="2" Grid.RowSpan="1" x:Name="TechnicalDetailsExpander">
                <Grid Height="Auto" Margin="5">
                    <TextBox Background="{x:Null}" x:Name="Details" Style="{DynamicResource Flamefusion_TextBox}" Height="56" VerticalAlignment="Top" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap" />
                    <CheckBox Style="{DynamicResource Flamefusion_CheckBox}" Foreground="White" IsChecked="True" Margin="0,55,0,0" VerticalAlignment="Top" Height="23.96" x:Name="CheckBox2" Content="Allow this to be shared with Flamefusion"/>
                </Grid>
            </Expander>
            <Button Foreground="White" HorizontalAlignment="Right" Margin="0,0,14,12" x:Name="Button1" Style="{DynamicResource Flamefusion_Button}" Width="89" Grid.Row="4" Height="31" VerticalAlignment="Bottom" Content="Button1"/>
            <Button Foreground="White" Margin="0,0,109,12" x:Name="Button2" Style="{DynamicResource Flamefusion_Button}" Grid.Row="4" HorizontalAlignment="Right" Width="89" Height="31" VerticalAlignment="Bottom" Content="Button2"/>
            <Button Foreground="White" HorizontalAlignment="Right" Margin="0,0,204,12" x:Name="Button3" Style="{DynamicResource Flamefusion_Button}" Width="89" Grid.Row="4" Height="31" VerticalAlignment="Bottom" Content="Button3"/>
        </Grid>
    </Window>


    - Mathy Flamefusion developer

모든 응답

  • 2008년 7월 9일 수요일 오전 4:26Marco Zhou 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    I cannot reproduce this problem, the code you pasted above works correctly for me, could you please elaborate if there is any other steps I need to follow to repro this issue.

    Thanks