繁体   English   中英

滚动条不可见-Stack Pannel

[英]Scroll bar not Visible - Stack Pannel

<StackPanel Name="CurrentInvoice" Margin="118,165,119,58" Opacity="100" Background="White">
        <TextBlock Name="Status" FontSize="16" Foreground="GreenYellow"/>
        <ListView Name="Invoices" Width="1000" HorizontalAlignment="Left" VerticalAlignment="Top" SelectionMode="None">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Height="35" HorizontalAlignment="Center" VerticalAlignment="Center" Width="1000">
                        <Border Background="#FF91C919" Width="102">
                            <TextBlock Text="{Binding TransactionHeaderId}" Margin="21,0,0,0" Foreground="White"  FontSize="30" Width="81" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Segoe UI" Height="35"></TextBlock>
                        </Border>
                        <Border Background="#FFF99B9B" Width="102">
                            <Button Foreground="White" Height="20" Width="55" Content="{Binding TransactionHeaderId}" Command="{Binding TestCommand}" Click="InvoiceOpen_Click" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="16,0,10,7" BorderBrush="{x:Null}">
                                <Button.Template>
                                    <ControlTemplate TargetType="Button">
                                        <Image Source="Assets/moreIcon.png"/>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                        </Border>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackPanel>

上面的代码用于在堆栈面板中显示项目,但是我无法添加滚动条。 我也使用了Scrollviewer。 这样做没有效果,所有的溢出都被隐藏了。 请为我找到一种添加滚动条的方法。(垂直/水平)

    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
 <StackPanel Name="CurrentInvoice" Margin="118,165,119,58" Opacity="100" Background="White">
    <TextBlock Name="Status" FontSize="16" Foreground="GreenYellow"/>
    <ListView Name="Invoices" Width="1000" HorizontalAlignment="Left" VerticalAlignment="Top" SelectionMode="None">
        <ListView.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal" Height="35" HorizontalAlignment="Center" VerticalAlignment="Center" Width="1000">
                    <Border Background="#FF91C919" Width="102">
                        <TextBlock Text="{Binding TransactionHeaderId}" Margin="21,0,0,0" Foreground="White"  FontSize="30" Width="81" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Segoe UI" Height="35"></TextBlock>
                    </Border>
                    <Border Background="#FFF99B9B" Width="102">
                        <Button Foreground="White" Height="20" Width="55" Content="{Binding TransactionHeaderId}" Command="{Binding TestCommand}" Click="InvoiceOpen_Click" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="16,0,10,7" BorderBrush="{x:Null}">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <Image Source="Assets/moreIcon.png"/>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </Border>
                </StackPanel>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
 </StackPanel>
</ScrollViewer>

将StackPanel放在这样的ScrollViewer中,并将VerticalScrollBarVisibility和Horizo​​ntalScrollBarVisibility都设置为可见。

<ScrollViewer VerticalScrollBarVisibility="Visible"  HorizontalScrollBarVisibility="Visible">
            <StackPanel Name="CurrentInvoice" Opacity="100" Background="White">
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
                <TextBlock Text="Test" Foreground="Black" FontSize="40"/>
            </StackPanel>

        </ScrollViewer>

如果您不希望滚动条一直显示,请将这两个设置设置为“自动”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM