Wpf多个GridSplitter行超出了窗口大小

时间:2015-12-11 03:38:03

标签: c# wpf gridsplitter

我有10行,每行之间有一个按钮,每个按钮之间的行有一个DockPanel

按钮的功能是完全折叠或使下一行内的DockPanel可见以折叠或再次显示 (通过visibility.collapse和可见)

我遇到的问题是,在将DockPanel返回到可见状态之后,该行不会再次重新生长,所以我必须通过存储其值来恢复其高度。

这导致我遇到问题,一旦行的高度恢复,其余的行不再适合窗口大小,并且它们可以超出窗口大小,

是否有解决此问题的解决方法

WPF:   

Sub UpdatenMove()
Dim ws As Worksheet

On Error Resume Next
Set ws = Sheets("Updated")
On Error GoTo 0

If Not ws Is Nothing Then
    MsgBox "This sheet already exists", vbCritical
Else
ActiveSheet.Copy After:=Sheets(1)
ActiveSheet.Name = "Updated"
End If

End Sub

CS:

    <Grid.RowDefinitions>
        <RowDefinition Height="20" Name="rowmenu"/>
        <RowDefinition Height="0"  Name="rowfirst" MinHeight="0"   MaxHeight="0"></RowDefinition>
        <RowDefinition Height="20" MinHeight="20" MaxHeight="20"/>
        <RowDefinition Height="81*"  Name="rowchapter" MinHeight="20"   ></RowDefinition>
        <RowDefinition Height="25" MinHeight="25" MaxHeight="25"/>
        <RowDefinition Height="81*"  Name="rowSongs"   MinHeight="20"   ></RowDefinition>
        <RowDefinition Height="25" MinHeight="25" MaxHeight="25"/>
        <RowDefinition Height="81*"   Name="rowImages"   MinHeight="20"      ></RowDefinition>
        <RowDefinition Height="25" MinHeight="25" MaxHeight="25" />
        <RowDefinition Height="81*"  Name="rowEfects"  MinHeight="20" ></RowDefinition>
        <RowDefinition Height="1*" MinHeight="1" Name="lastrow"  />

    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="417*"/>
        <ColumnDefinition Width="100*"/>
    </Grid.ColumnDefinitions>

 <Button 
        Name="HeaderChapters" 
        Content="Chapters"  
        Margin="5,0,0,0" 
        HorizontalContentAlignment="Center" 
        Grid.Column="1" 
        Grid.Row="2" 
        VerticalAlignment="Top"  
        BorderBrush="CornflowerBlue" 
        BorderThickness="1" 
        Click="Button_Click"/>

    <DockPanel Name="chaptersdock" Grid.Column="1" Grid.Row="3" Margin="5,0,0,0"  >
            <ScrollViewer VerticalScrollBarVisibility="Auto" >
            <ItemsControl  Name="ChaptersControl" BorderBrush="CornflowerBlue" BorderThickness="3" >

            </ItemsControl>
            </ScrollViewer>
    </DockPanel>

    <Button Name="HeaderSongs" 
            Content="songs"  
            Margin="5,5,0,0" 
            HorizontalContentAlignment="Center" 
            Grid.Column="1" Grid.Row="4" 
            VerticalAlignment="Top"  
            BorderBrush="GreenYellow"  
            BorderThickness="1" 
            Click="Button_Click"/>

    <DockPanel Name="songsdoc" Grid.Column="1" Grid.Row="5" Margin="5,0,0,0"  >
        <ScrollViewer VerticalScrollBarVisibility="Auto" >
            <ItemsControl  Name="songsControl" BorderBrush="GreenYellow" BorderThickness="3" >

            </ItemsControl>
        </ScrollViewer>
    </DockPanel>

    <Button Name="HeaderImages" Content="Images"  
            Margin="5,5,0,0" HorizontalContentAlignment="Center" 
            Grid.Column="1" Grid.Row="6" VerticalAlignment="Top"  BorderBrush="Salmon"  BorderThickness="1" Click="Button_Click"/>

    <DockPanel Name="Imagesdoc" Grid.Column="1" Grid.Row="7" Margin="5,0,0,0"  >
        <ScrollViewer VerticalScrollBarVisibility="Auto" >
            <ItemsControl  Name="ImagesControl" BorderBrush="Salmon" BorderThickness="3" >

            </ItemsControl>
        </ScrollViewer>
    </DockPanel>

    <Button Name="HeaderEfects" Content="Efects"  Margin="5,5,0,0" HorizontalContentAlignment="Center" Grid.Column="1" Grid.Row="8" VerticalAlignment="Top"  BorderBrush="Purple"  BorderThickness="1" Click="Button_Click"/>
    <DockPanel Name="Efectsdoc" Grid.Column="1" Grid.Row="9" Margin="5,0,0,0"  >
        <ScrollViewer VerticalScrollBarVisibility="Auto" >
            <ItemsControl  Name="EfectsControl" BorderBrush="Purple" BorderThickness="3" >

            </ItemsControl>
        </ScrollViewer>
    </DockPanel>

    <GridSplitter  Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch"  Width="5" HorizontalAlignment="Left" Grid.RowSpan="13" />
    <GridSplitter Name="GridSplitterChapters" Grid.Row="4" Grid.Column="1" VerticalAlignment="Top" Height="5" HorizontalAlignment="Stretch" Grid.RowSpan="1" DragStarted="GridSplitterImages_DragStarted" />
    <GridSplitter Name="GridSplitterSongs" Grid.Row="6" Grid.Column="1" VerticalAlignment="Top" Height="5" HorizontalAlignment="Stretch" Grid.RowSpan="1" DragStarted="GridSplitterImages_DragStarted"  />
    <GridSplitter Name="GridSplitterImages" Grid.Row="8" Grid.Column="1" VerticalAlignment="Top" Height="5" HorizontalAlignment="Stretch" Grid.RowSpan="1" DragStarted="GridSplitterImages_DragStarted" />

0 个答案:

没有答案