use*_*612 11 silverlight grid xaml scrollviewer
我的XAML看起来像这样
<navigation:Page x:Class="SilverlightApplication1.Home">
<Grid x:Name="LayoutRoot">
<!--
<ScrollViewer>
<Grid>
<TextBlock Text="myTextBlock" />
</Grid>
</ScrollViewer>
-->
</Grid>
Run Code Online (Sandbox Code Playgroud)
我想以编程方式通过后面的代码执行上面的注释部分.
我的代码背后看起来像这样
public partial class Home : Page
{
public Home()
{
InitializeComponent();
ScrollViewer sv = new ScrollViewer();
Grid grid = new Grid();
TextBlock block = new TextBlock();
block.Text = "My Text block";
grid.Children.Add(block);
sv.ScrollIntoView(grid);
LayoutRoot.Children.Add(sv);
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为它只显示滚动查看器但隐藏了文本块.
我错过了什么?
有没有办法使用silverlight工具包中提供的扩展方法"ScrollIntoView"以编程方式将子项添加到"ScrollViewer"控件?我没有为ScrollViewer元素找到一个名为"Children"的属性
谢谢您的帮助
Jus*_* XL 18
您没有指定ScrollViewer
内容,只是在最后一行之前执行此操作.您也可以删除该ScrollIntoView
方法.
sv.Content = grid;
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你.:)
归档时间: |
|
查看次数: |
10998 次 |
最近记录: |