簡體   English   中英

換行面板上的WPF滾動條顯示為灰色

[英]WPF scroll bar on wrap panel grayed out

我已經閱讀了很多相關主題,但找不到解決方案。 在WPF中,我試圖在包裝面板上放置一個垂直滾動條。 我正在動態構建包裝面板,它有標簽和文本框。 這是我的包裹面板包裹在滾動查看器中...

<ScrollViewer VerticalScrollBarVisibility="Visible" CanContentScroll="True" IsEnabled="True" AllowDrop="True">
                        <WrapPanel Orientation="Horizontal" Name="wpAddAttribute" Width="1129" IsEnabled="True" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible"></WrapPanel>
                    </ScrollViewer>

這是動態構建每一行的C#代碼......

private void AddAttribute(object sender, RoutedEventArgs e)
        {
            wpAddAttribute.Children.Add(new Label { Content = "Attribute Name", Name = "lbNewTestAttributeNameLabel" });
            wpAddAttribute.Children.Add(new TextBox { Height = 26, Name = "tbNewTestAttributeName", Width = 75 });
            wpAddAttribute.Children.Add(new Label { Content = "Attribute Value", Name = "lbNewTestAttributeValueLabel" });
            wpAddAttribute.Children.Add(new TextBox { Height = 26, Name = "tbNewTestAttributeValue", Width = 55 });
            wpAddAttribute.Children.Add(new Label { Content = "Attribute Units", Name = "lbNewTestAttributeUnitsLabel" });
            wpAddAttribute.Children.Add(new TextBox { Height = 26, Name = "tbNewTestAttributeUnits", Width = 55 });

            wpAddAttribute.Children.Add(new Label { Content = "Attribute Minimum Value", Name = "lbNewTestAttributeMinValueLabel" });
            wpAddAttribute.Children.Add(new TextBox { Height = 26, Name = "tbNewTestAttributeMinValue", Width = 55 });
            wpAddAttribute.Children.Add(new Label { Content = "Attribute Maximum Value", Name = "lbNewTestAttributeMaxValueLabel" });
            wpAddAttribute.Children.Add(new TextBox { Height = 26, Name = "tbNewTestAttributeMaxValue", Width = 55 });

            wpAddAttribute.Children.Add(new Label { Content = "Stepping Minimum Value", Name = "lbNewTestSteppingMinValueLabel" });
            wpAddAttribute.Children.Add(new TextBox { Height = 26, Name = "tbNewTestAttributeMinValue", Width = 55 });
                        }

我確實在屏幕右側看到一個垂直滾動條,但它總是變灰,即使我超出了我所處的空間。有關如何滾動/不灰顯的任何想法?

這是我的包裝面板與父邊框容器...

 <Border Name="bdAddTestArea" Visibility="Collapsed" Background="DeepSkyBlue" BorderThickness="2" BorderBrush="Black" CornerRadius="10"  Margin="10" Width="1130" Height="330" ScrollViewer.CanContentScroll="True">
            <StackPanel ScrollViewer.CanContentScroll="True">
                <StackPanel Orientation="Vertical" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <TextBlock Margin="4 0 0 0">Add a Test</TextBlock>
                    <StackPanel Orientation="Horizontal">
                        <Label Content="New Test Name:"></Label>
                        <TextBox Name="tbNewTestName" Width="75"></TextBox>
                        <Label Content="Test Estimate (in seconds):"></Label>
                        <TextBox Name="tbTestEstimate" Width="75"></TextBox>
                    </StackPanel>
                    <ScrollViewer VerticalScrollBarVisibility="Visible" CanContentScroll="True" IsEnabled="True" AllowDrop="True">
                        <WrapPanel Orientation="Horizontal" Name="wpAddAttribute" Width="1129" IsEnabled="True" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible"></WrapPanel>
                    </ScrollViewer>
                </StackPanel>

                <StackPanel Visibility="Visible" Orientation="Horizontal" >
                </StackPanel>
                <Button Content="Add an Attribute" Click="AddAttribute" Width="96" Margin="5 5 0 0" HorizontalAlignment="Left"></Button>
                <Button Content="Save Test" Click="SaveTest" Height="20" HorizontalAlignment="Left" Margin="5 5 0 0"></Button>
                <Button Content="Return To Test Selection" Click="ReturnToSelectionPanel" Height="20" HorizontalAlignment="Left" Margin="5 5 0 0"></Button>

            </StackPanel>
        </Border>

如果要垂直實現包裝面板的方向為水平,請將方向更改為“垂直”。 那時工作正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM