简体   繁体   English

Windows Phone 8.1 Silverlight中的Stackpanel和TextBlock

[英]Stackpanel and textblock in windows phone 8.1 Silverlight

I have this textblock inside a stackpanel in my app where I keep a log of all the exceptions that occur in my app. 我在我的应用程序的堆栈面板中有此文本块,在其中记录了我的应用程序中发生的所有异常的日志。 The problem is, at a certain length, the text just stops rendering and I get a textblock with a chopped text (it basically stops showing text and the last line is cut horizontally. Decreasing the font size helps though). 问题是,在一定的长度下,文本只是停止渲染,而我得到的文本块带有切碎的文本(基本上停止显示文本,最后一行被水平剪切。减小字体大小虽然有帮助)。 By scrolling down further, I just get a blank textblock with the length that it's supposed to have. 通过进一步向下滚动,我得到了一个空白的文本块,其长度应为预期长度。 Both the stackpanel and the textblock in my app have the height set to "Auto". 我的应用程序中的stackpanel和textblock都将高度设置为“自动”。 Any idea what I should do to be able to see the whole text? 知道我应该怎么做才能看到全文吗?

XAML: XAML:

        <ListBox x:Name="List">
            <ListBox.ItemTemplate>
            <DataTemplate>
             // TextBlock to display Exception String... Here I Binded Using ErrorText String
                    <TextBlock Text="{Binding ErrorText}" TextWrapping="Wrap" Margin="0,0,0,15"/>
                </DataTemplate>
            </ListBox.ItemTemplate>                
        </ListBox>

C#: C#:

// Class to Store your String Exceptions
public class Errors
{
   // String Exception Error 
    public string ErrorText { get; set; }

    public Errors(string error)
    {
        this.ErrorText = error;
    }
}

  // Code to Add exception error to ListBox Itemssource. Before this create List that having Error like this.

    List<Errors> ErrorsSource = new List<Errors>();
   ErrorsSource.Add(new Errors("Error   1   Value of type 'System.IO.FileAccess' cannot be 
converted to 'System.IO.IsolatedStorage.IsolatedStorageFile'"));

    ErrorsSource.Add(new Errors( "The exception (Operation not permitted on 
IsolatedStorageFileStream.) occurs at _Play function while reading the file "));

    List.ItemsSource = ErrorsSource;

Let me know whether you got this properly or not. 让我知道您是否正确地做到了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM