[英]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和HorizontalScrollBarVisibility都設置為可見。
<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.