Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
垂直转换时防止WPF剪裁网格内容_Wpf_Xaml - Fatal编程技术网

垂直转换时防止WPF剪裁网格内容

垂直转换时防止WPF剪裁网格内容,wpf,xaml,Wpf,Xaml,我有下面的XAML,它显示文本块的堆栈面板。由于我的主网格大小,堆栈面板中的最后几项自然会被剪裁。但是,如果垂直向上平移堆栈面板的父网格(而不是主网格),堆栈面板的内容仍然会被剪裁,而不是在底部显示项目。如何在不剪裁堆栈面板底部内容的情况下在网格上执行垂直平移 Viewbox很重要,因为第一个网格需要将自身大小调整为主窗口或监视器的最大高度 <Window x:Class="WpfApplication5.MainWindow" xmlns="http://schemas.

我有下面的XAML,它显示文本块的堆栈面板。由于我的主网格大小,堆栈面板中的最后几项自然会被剪裁。但是,如果垂直向上平移堆栈面板的父网格(而不是主网格),堆栈面板的内容仍然会被剪裁,而不是在底部显示项目。如何在不剪裁堆栈面板底部内容的情况下在网格上执行垂直平移

Viewbox很重要,因为第一个网格需要将自身大小调整为主窗口或监视器的最大高度

<Window x:Class="WpfApplication5.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow">
    <Viewbox>
        <Grid Width="500" Height="888" Background="#cccccc">
            <Grid Background="#cc99cc">
                <Grid.RenderTransform>
                    <TranslateTransform Y="-800"/>
                </Grid.RenderTransform>
                <StackPanel>
                    <TextBlock Text="This is a test 1" FontSize="50" Foreground="Blue"/>
                    <TextBlock Text="This is a test 2" FontSize="50" Foreground="Red"/>
                    <TextBlock Text="This is a test 3" FontSize="50" Foreground="Green"/>
                    <TextBlock Text="This is a test 4" FontSize="50" Foreground="Orange"/>
                    <TextBlock Text="This is a test 5" FontSize="50" Foreground="Yellow"/>
                    <TextBlock Text="This is a test 6" FontSize="50" Foreground="Purple"/>
                    <TextBlock Text="This is a test 7" FontSize="50" Foreground="Blue"/>
                    <TextBlock Text="This is a test 8" FontSize="50" Foreground="Red"/>
                    <TextBlock Text="This is a test 9" FontSize="50" Foreground="Green"/>
                    <TextBlock Text="This is a test 10" FontSize="50" Foreground="Orange"/>
                    <TextBlock Text="This is a test 11" FontSize="50" Foreground="Yellow"/>
                    <TextBlock Text="This is a test 12" FontSize="50" Foreground="Purple"/>
                    <TextBlock Text="This is a test 13" FontSize="50" Foreground="Blue"/>
                    <TextBlock Text="This is a test 14" FontSize="50" Foreground="Red"/>
                    <TextBlock Text="This is a test 15" FontSize="50" Foreground="Green"/>
                    <TextBlock Text="This is a test 16" FontSize="50" Foreground="Orange"/>
                </StackPanel>
            </Grid>
        </Grid>
    </Viewbox>
</Window>

只需取出网格上的Height属性即可

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Name="Wind1"
        Title="MainWindow">
    <Viewbox>
        <Grid Width="500" Background="#cccccc">
            <Grid Background="#cc99cc">
                <Grid.RenderTransform>
                    <TranslateTransform Y="-800"/>
                </Grid.RenderTransform>
                <StackPanel x:Name="stack1">
                    <TextBlock Text="This is a test 1" FontSize="50" Foreground="Blue"/>
                    <TextBlock Text="This is a test 2" FontSize="50" Foreground="Red"/>
                    <TextBlock Text="This is a test 3" FontSize="50" Foreground="Green"/>
                    <TextBlock Text="This is a test 4" FontSize="50" Foreground="Orange"/>
                    <TextBlock Text="This is a test 5" FontSize="50" Foreground="Yellow"/>
                    <TextBlock Text="This is a test 6" FontSize="50" Foreground="Purple"/>
                    <TextBlock Text="This is a test 7" FontSize="50" Foreground="Blue"/>
                    <TextBlock Text="This is a test 8" FontSize="50" Foreground="Red"/>
                    <TextBlock Text="This is a test 9" FontSize="50" Foreground="Green"/>
                    <TextBlock Text="This is a test 10" FontSize="50" Foreground="Orange"/>
                    <TextBlock Text="This is a test 11" FontSize="50" Foreground="Yellow"/>
                    <TextBlock Text="This is a test 12" FontSize="50" Foreground="Purple"/>
                    <TextBlock Text="This is a test 13" FontSize="50" Foreground="Blue"/>
                    <TextBlock Text="This is a test 14" FontSize="50" Foreground="Red"/>
                    <TextBlock Text="This is a test 15" FontSize="50" Foreground="Green"/>
                    <TextBlock Text="This is a test 16" FontSize="50" Foreground="Orange"/>
                </StackPanel>
            </Grid>
        </Grid>
    </Viewbox>
</Window>