Windows phone 7 ScrollViewer没有';卷轴
大约一周前,我开始了WP7的开发(通常是编程),我一直在开发一个小应用程序,但我在让ScrollViewer正常工作时遇到了一个问题 当满足某些条件时,应用程序会创建一个新的透视项,我正在尝试在其中添加一个可滚动的文本块,每次用户点击屏幕时,它都会显示从列表中随机选择的文本字符串,其中一些字符串足够长,需要垂直滚动Windows phone 7 ScrollViewer没有';卷轴,windows-phone-7,scrollviewer,Windows Phone 7,Scrollviewer,大约一周前,我开始了WP7的开发(通常是编程),我一直在开发一个小应用程序,但我在让ScrollViewer正常工作时遇到了一个问题 当满足某些条件时,应用程序会创建一个新的透视项,我正在尝试在其中添加一个可滚动的文本块,每次用户点击屏幕时,它都会显示从列表中随机选择的文本字符串,其中一些字符串足够长,需要垂直滚动 // A bit cleaned version of my code, // had to translate stuff a bit for them to make sens
// A bit cleaned version of my code,
// had to translate stuff a bit for them to make sense
// Sets the PivotItem header depending on user choice
// and creates ScrollViewer and TextBlock
PivotItem newPivotItem = new PivotItem { Header = choice, Name = "newPivot"};
ScrollViewer newScrollviewer = new ScrollViewer();
TextBlock newTextBlock = new TextBlock { Text = "tap the screen", Name = choice};
newScrollviewer.Content = newTextBlock;
newPivotItem.Content = newScrollviewer;
mainPivot.Items.Add(newPivotItem);
文本添加到Tap事件中,该事件仅用新字符串替换文本属性。文本更新正常,但ScrollViever在更新后停止工作
newString = list[rand];
PivotItem selectedPivot = mainPivot.SelectedItem as PivotItem;
TextBlock selectedText = selectedPivot.FindName(choice) as TextBlock;
selectedText.Text = newString;
selectedText.Height = selectedText.ActualHeight;
类似的ScrollViewer-在xaml中声明的另一个PivotItem中的TextBlock组合工作得很好。我发现真正破坏ScrollViewer的是转换动画,我已将其设置为在文本更新时触发。我在上面有一点输入错误,不知怎么的,当转换工作时,scrollviewer没有