0
votes

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". Any idea what I should do to be able to see the whole text?

1
I would recommend using a list, where you put your exception textblocks into, instead of one big textblock - thumbmunkeys
Can you help me a bit? I'm a beginner and I've never used lists before. - George Mihăilă
replace your textblock with a listbox. add the exception strings to listbox.items - thumbmunkeys

1 Answers

0
votes

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;

Let me know whether you got this properly or not.