C# ScrollViewer Windows 8 XAML中的多个堆栈面板
我似乎在ScrollViewer中添加多个StackPanel时遇到问题。我可以添加第一个,它会显示我想要的数据,但当我尝试添加第二个StackPanel时失败,并导致错误“将复制分配到'ScrollViewer'对象的'Content'属性” 我的前端代码如下所示:C# ScrollViewer Windows 8 XAML中的多个堆栈面板,c#,xaml,windows-store-apps,scrollviewer,C#,Xaml,Windows Store Apps,Scrollviewer,我似乎在ScrollViewer中添加多个StackPanel时遇到问题。我可以添加第一个,它会显示我想要的数据,但当我尝试添加第二个StackPanel时失败,并导致错误“将复制分配到'ScrollViewer'对象的'Content'属性” 我的前端代码如下所示: <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisib
<ScrollViewer VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Visible"
ZoomMode="Disabled"
Grid.Column="1"
Grid.Row="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<StackPanel Style='{StaticResource BlueFirstStackPanel}'>
<TextBlock Text='Facility Patient Number:'
Style='{StaticResource TextBlockStyle}' />
<TextBox Style='{StaticResource TextBoxStyle}' />
<TextBlock Text='Patient Number:'
Style='{StaticResource TextBlockStyle}' />
<TextBox Style='{StaticResource TextBoxStyle}' />
<TextBlock Text='Patient Support Number:'
Style='{StaticResource TextBlockStyle}' />
<TextBox Style='{StaticResource TextBoxStyle}' />
<TextBlock Text='NHIF Number:'
Style='{StaticResource TextBlockStyle}' />
<TextBox Style='{StaticResource TextBoxStyle}' />
<TextBlock Text='Patient National ID:'
Style='{StaticResource TextBlockStyle}' />
<TextBox Style='{StaticResource TextBoxStyle}' />
</StackPanel>
</ScrollViewer>
上面的显示非常好,但是当我添加第二个StackPanel时,它会带来一个错误。有什么帮助吗?ScrollViewer只能有一个子控件。尝试将两个StackPanel包装在网格或另一个StackPanel中:
<ScrollViewer>
<StackPanel x:Name="ScrollViewerChild">
<StackPanel x:Name="StackPanel1">
</StackPanel>
<StackPanel x:Name="StackPanel2">
</StackPanel>
</StackPanel>
</ScrollViewer>
<ScrollViewer>
<StackPanel x:Name="ScrollViewerChild">
<StackPanel x:Name="StackPanel1">
</StackPanel>
<StackPanel x:Name="StackPanel2">
</StackPanel>
</StackPanel>
</ScrollViewer>