2014-09-06 152 views
0

我在我的应用程序中的一个stackpanel内有这个文本块,其中我保留了在我的应用程序中发生的所有异常的日志。问题是,在一定的长度,文本只是停止渲染,我得到一个带有斩文字的文本块(它基本上停止显示文本,最后一行被水平切割,尽管减小字体大小有帮助)。通过进一步滚动,我只是得到一个空白的文本块,其长度应该是。我的应用程序中的堆叠面板和文本块的高度都设置为“自动”。任何想法我应该怎么做才能看到整个文本?在Windows Phone 8.1中的Stackpanel和textblock Silverlight

+0

我会推荐使用一个列表,在那里你把你的例外文本块,而不是一个大的文本块 – thumbmunkeys 2014-09-06 15:56:42

+0

你能帮我一下吗?我是一名初学者,我从未使用过列表。 – 2014-09-06 16:01:17

+0

用列表框替换您的文本块。将例外字符串添加到'listbox.items' – thumbmunkeys 2014-09-06 16:14:12

回答

0

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#:

// 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; 

让我知道你是否有这个正确与否。

相关问题