Reputation: 79
I have a LongListSelector
and use inside it a RichTextBox
<DataTemplate>
<Grid>
<RichTextBox>
<Paragraph>
<Run Text="{Binding Description}"/>
</Paragraph>
</RichTextBox>
</Grid>
</DataTemplate>
because of a long list of data, there is a delay in appearing RichTextBox
's data. everything is loaded but texts appear later.
No problem with a delay, but It gets annoying when I try to scroll to a particular item in LongListSelector
by its .ScrollTo
method. In the Loaded
event handler of the form or the LLS (no difference) I call ScrollTo
but its execution finishes and scrolls to the item before appearing the text of RichTextBox
on the screen, So after appearing the text, it gets longer, and it is not on the right item any more.
I thought of a delay in executing the ScrollTo
method, to let everything appear in the screen, but since my app is not multithread, I couldn't end up with a successful sleep or timer.
How can I solve this? How can I wait until RichTextBox
's loading finished?
(It's a WP8 app)
Upvotes: 1
Views: 214
Reputation: 3506
Try to implement Property Change Notification
public class YourClass: INotifyPropertyChanged
{
private string description;
public event PropertyChangedEventHandler PropertyChanged;
public string Description
{
get { return description; }
set
{
description= value;
OnPropertyChanged("Description");
}
}
// Create the OnPropertyChanged method to raise the event
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
}
And when you set Description = "blablabla"
it will notify your RichTextBox
.
Hope it's help
Upvotes: 0
Reputation: 4331
You could try using LayoutUpdated(), the last time it fires the content is loaded.
Upvotes: 1