I seem to have a sluggish user interface when trying to scroll through any large text blocks ...
What is the best way to do this in WP 8.1?
Here is an example that I did to illustrate this problem, note when the application starts, the frame rate drops terribly.
I already looked BackgroundWorkerand it doesn't seem to exist in WP 8.1.
MainPage.xaml
<Page
x:Class="HTTPRequest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HTTPRequest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<ScrollViewer x:Name="scroll" Margin="10,13,0,10" Width="380" MaxZoomFactor="4" VerticalScrollMode="Enabled" HorizontalScrollMode="Disabled" IsTapEnabled="False">
<TextBlock x:Name="RSSData" TextWrapping="Wrap" Text="Loading..." FontSize="22" VerticalAlignment="Top"/>
</ScrollViewer>
<ProgressBar x:Name="prog" Height="16" Margin="101,310,101,0" VerticalAlignment="Top" IsIndeterminate="True"/>
</Grid>
</Page>
MainPage.xaml.cs
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using Windows.Data.Xml.Dom;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace HTTPRequest
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
Main();
}
private async void Main()
{
string results = await DownloadXMLDocument();
prog.Visibility = Visibility.Collapsed;
RSSData.Text = results;
}
public async Task<string> DownloadXMLDocument()
{
string URLString = "http://www.packtpub.com/rss.xml";
Uri uri = new Uri(URLString);
XmlDocument xmlDocument = await XmlDocument.LoadFromUriAsync(uri);
return xmlDocument.GetXml();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
}
}
source
share