gpt4 book ai didi

c# - 处理 Windows Phone 8.1 中 UI 性能问题的最佳方法

转载 作者:太空狗 更新时间:2023-10-30 00:52:00 25 4
gpt4 key购买 nike

当我尝试滚动任何大的 TextBlocks 时,我的 UI 似乎很慢...
在 WP 8.1 中解决这个问题的最佳方法是什么?

我举了一个例子来说明这个问题,请注意当应用程序运行时帧率会急剧下降。
我已经查找过 BackgroundWorker,它似乎不存在于 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;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641

namespace HTTPRequest
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
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();
}



/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// TODO: Prepare page for display here.

// TODO: If your application contains multiple pages, ensure that you are
// handling the hardware Back button by registering for the
// Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
// If you are using the NavigationHelper provided by some templates,
// this event is handled for you.
}
}
}

最佳答案

单个 TextBox 中存在大量文本的已知问题。而是尝试使用 RichTextBox 并查看您的性能是否有所提高。抱歉,您遇到了问题。

祝你好运!

关于c# - 处理 Windows Phone 8.1 中 UI 性能问题的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24017942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com