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;
讓我知道你是否有這個正確與否。
我會推薦使用一個列表,在那裏你把你的例外文本塊,而不是一個大的文本塊 – thumbmunkeys 2014-09-06 15:56:42
你能幫我一下嗎?我是一名初學者,我從未使用過列表。 – 2014-09-06 16:01:17
用列表框替換您的文本塊。將例外字符串添加到'listbox.items' – thumbmunkeys 2014-09-06 16:14:12