0
votes

i've started WP7 development about a week ago (and programming in general) and I've been working on a little app, but i faced a problem with getting ScrollViewer to function properly.

Application creates a new pivot item when certain conditions are met, and i'm trying to add a scrollable textblock in it, which shows randomly chosen strings of text from a list every time user taps the screen, from which some are long enough to require vertical scrolling.

// 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);

Text is added in Tap event, which just replaces the Text property with new string. Text updates just fine and as intended, but ScrollViever stops working after update.

newString = list[rand];
PivotItem selectedPivot = mainPivot.SelectedItem as PivotItem;                
TextBlock selectedText = selectedPivot.FindName(choice) as TextBlock;
selectedText.Text = newString;
selectedText.Height = selectedText.ActualHeight;

Similiar ScrollViewer - TextBlock combination in another PivotItem which is declared in xaml works just fine.

1

1 Answers

1
votes

I found what actually broke the ScrollViewer, it was transition animation which i had set to trigger on text update. I had a little typing error on it and somehow while the transition worked, scrollviewer didn't.