Windows phone 7 Silverlight文本块可以容纳多少个字符?
我试图将最终用户许可协议EULA放入WP7 silverlight textblock控件中。但是,它不断截断我的文本。为什么会这样?WP7 silverlight文本块可容纳的文本大小或字符数是否有限制 下面是我在xaml方面所做的一个示例,xaml环境的其余部分是自动生成的默认值Windows phone 7 Silverlight文本块可以容纳多少个字符?,windows-phone-7,textblock,Windows Phone 7,Textblock,我试图将最终用户许可协议EULA放入WP7 silverlight textblock控件中。但是,它不断截断我的文本。为什么会这样?WP7 silverlight文本块可容纳的文本大小或字符数是否有限制 下面是我在xaml方面所做的一个示例,xaml环境的其余部分是自动生成的默认值 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <ScrollViewer> <Tex
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer>
<TextBlock x:Name="tbMsg" TextWrapping="Wrap"/>
</ScrollViewer>
</Grid>
我也尝试过使用文本框,但现在,我甚至无法在文本框中滚动。我已经明确地将VerticalScrollBarVisibility设置为Visible,但仍然无法向下滚动文本框。事实上,我甚至没有看到垂直滚动条。我不知道这是否是因为我仍在通过模拟器查看UI
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBox x:Name="tbMsg" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible"/>
</Grid>
这可能是几件事-文本块的高度可能受到另一个控件的限制,应用于文本的样式可能导致它
你能发布你的源代码吗?可能有几件事-文本块的高度可能受到另一个控件的限制,应用于文本的样式可能导致它 您可以发布源代码吗?任何UIElement在方向、高度或宽度上都不能大于2048像素。任何超出此区域显示的内容都不会显示。不过,可视树中保留了此内容的存储空间 解决方法是使用多个元素来显示大量文本 更新 我已经为动态显示这类内容编写了自己的解析器。但理想情况下,您不会在运行时处理大块文本。当文本包含指向其他页面、web内容或电子邮件启动器的链接时,这可能会更加复杂 当想要显示EULA或任何大型文本时,您不想让用户阅读和导航变得容易。毕竟,你是包括文本,因为你希望用户阅读它 如果您在设计时有文本,您应该借此机会确保它的布局适当,并且为不同的部分使用单独的文本块,适当地设置标题和子标题的样式可以帮助您做到这一点。任何UIElement在方向、高度或宽度上都不能大于2048像素。任何超出此区域显示的内容都不会显示。不过,可视树中保留了此内容的存储空间 解决方法是使用多个元素来显示大量文本 更新 我已经为动态显示这类内容编写了自己的解析器。但理想情况下,您不会在运行时处理大块文本。当文本包含指向其他页面、web内容或电子邮件启动器的链接时,这可能会更加复杂 当想要显示EULA或任何大型文本时,您不想让用户阅读和导航变得容易。毕竟,你是包括文本,因为你希望用户阅读它
如果您在设计时有文本,您应该借此机会确保它的布局适当,并且为不同的部分使用单独的文本块,适当地设置标题和子标题的样式可以帮助您做到这一点。我想与您分享这段代码。它会创建大量文本块并将其作为子项添加到Stackpanel。您可以在Scroll viewer中创建Stackpanel,因为Scrollvewers只能直接获取单个子元素
//constructor
List<char> countStoryvar = new List<char>(); //to store the text Body
private string incStorybody;
private int textMax = 2000; //You can modify this.
//methods
private void PlaceData()
{
incStorybody = "Your Story Source";
int countStory = incStorybody.Count();
countStoryvar = incStorybody.ToList();
double countStoryd = double.Parse(countStory.ToString());
if (countStoryd < textMax)
{
TextBlock txtBlock = new TextBlock();
txtBlock.TextWrapping = TextWrapping.Wrap;
readStackPanel.Children.Add(txtBlock);
}
else
{
double countStoryd2 = countStoryd / textMax; //fetch divisions
countStoryd2 = Math.Round(countStoryd2, 5); //getting Real no
string sountstring = countStoryd2.ToString();
string[] split = sountstring.Split(new string[] { "." }, StringSplitOptions.None); //to remove decimal
int countStoryi = int.Parse(split[0]);
int remainder = countStory - (textMax * countStoryi);
int iterationtimestin = countStoryi + 1;
for (int z = 0; z < iterationtimestin; z++)
{
int zlast = countStoryi - 1;
int multiple = 0;
int multiple1 = 0;
int multiplecounter = 0;
multiple = textMax * z;
if (z == 0)
{
multiplecounter = textMax;
}
else
{
if (z == countStoryi)
{
multiplecounter = countStory;
}
else
{
multiple1 = z + 1;
multiplecounter = textMax * multiple1;
}
}
LoadStackPanel(multiple, multiplecounter);
}
}
}
private void LoadStackPanel(int starting, int ending)
{
TextBlock txtBlock = new TextBlock();
txtBlock.TextWrapping = TextWrapping.Wrap;
for (int zi = starting; zi < ending; zi++)
{
incStoryInput = incStoryInput + countStoryvar[zi];
}
txtBlock.Text = incStoryInput;
readStackPanel.Children.Add(txtBlock);
incStoryInput = string.Empty;
}
我想和你分享这段代码。它会创建大量文本块并将其作为子项添加到Stackpanel。您可以在Scroll viewer中创建Stackpanel,因为Scrollvewers只能直接获取单个子元素
//constructor
List<char> countStoryvar = new List<char>(); //to store the text Body
private string incStorybody;
private int textMax = 2000; //You can modify this.
//methods
private void PlaceData()
{
incStorybody = "Your Story Source";
int countStory = incStorybody.Count();
countStoryvar = incStorybody.ToList();
double countStoryd = double.Parse(countStory.ToString());
if (countStoryd < textMax)
{
TextBlock txtBlock = new TextBlock();
txtBlock.TextWrapping = TextWrapping.Wrap;
readStackPanel.Children.Add(txtBlock);
}
else
{
double countStoryd2 = countStoryd / textMax; //fetch divisions
countStoryd2 = Math.Round(countStoryd2, 5); //getting Real no
string sountstring = countStoryd2.ToString();
string[] split = sountstring.Split(new string[] { "." }, StringSplitOptions.None); //to remove decimal
int countStoryi = int.Parse(split[0]);
int remainder = countStory - (textMax * countStoryi);
int iterationtimestin = countStoryi + 1;
for (int z = 0; z < iterationtimestin; z++)
{
int zlast = countStoryi - 1;
int multiple = 0;
int multiple1 = 0;
int multiplecounter = 0;
multiple = textMax * z;
if (z == 0)
{
multiplecounter = textMax;
}
else
{
if (z == countStoryi)
{
multiplecounter = countStory;
}
else
{
multiple1 = z + 1;
multiplecounter = textMax * multiple1;
}
}
LoadStackPanel(multiple, multiplecounter);
}
}
}
private void LoadStackPanel(int starting, int ending)
{
TextBlock txtBlock = new TextBlock();
txtBlock.TextWrapping = TextWrapping.Wrap;
for (int zi = starting; zi < ending; zi++)
{
incStoryInput = incStoryInput + countStoryvar[zi];
}
txtBlock.Text = incStoryInput;
readStackPanel.Children.Add(txtBlock);
incStoryInput = string.Empty;
}
我不认为文本大小或限制有限制。但内存可能会有限制,所以如果文件太大,超过10MB,则可能会导致问题。您还应该尝试在滚动面板中包装文本块以启用滚动。我的eula.txt文件已设置为内容,不复制。在windows 7上,通过查看其属性,其文件大小为5.95 KB,磁盘大小不同,显示为8.00 KB。在记事本++中查看my eula.txt,其长度为69行6093个字符。它以UTF-8格式保存。最后,我不熟悉滚动面板,这是一个与现成wp7 silverlight sdk无关的控件,即wp7工具包中的某个地方吗?我使用了ScrollViewer控件,它似乎在做我想做的事情,除了截断。当我将代码放入调试器并查看我的字符串时,它被完全读取到最后,只是没有正确显示。我认为文本大小或限制没有限制。但内存可能会有限制,所以如果文件太大,超过10MB,则可能会导致问题。您还应该尝试在滚动面板中包装文本块以启用滚动。我的eula.txt文件已设置为“内容”和“执行”
不抄袭。在windows 7上,通过查看其属性,其文件大小为5.95 KB,磁盘大小不同,显示为8.00 KB。在记事本++中查看my eula.txt,其长度为69行6093个字符。它以UTF-8格式保存。最后,我不熟悉滚动面板,这是一个与现成wp7 silverlight sdk无关的控件,即wp7工具包中的某个地方吗?我使用了ScrollViewer控件,它似乎在做我想做的事情,除了截断。当我将代码放入调试器并查看我的字符串时,它被完全读取到最后,只是没有正确显示。你能给我一个关于这种方法的链接吗?@user373312-这篇博文很好@matt wow,这就是我所能说的。要实现这一点是非常重要的,代码中已经清楚地说明了这一点。谢谢你的链接。我也遇到了同样的问题,决定用NavigateToString将它放在WebBrowser控件中。你可能想试试。你能给我一个关于这种方法的链接吗?@user373312-这篇博文很好@matt wow,这就是我能说的。要实现这一点是非常重要的,代码中已经清楚地说明了这一点。谢谢你的链接。我也遇到了同样的问题,决定用NavigateToString将它放在WebBrowser控件中。你可能想试试。我修改了原来的帖子。我修改了原来的帖子。