I know what’s wrong, I don’t know how to fix it.
I get a
NullReferenceException:Object reference not set to an instance of an object.
I get this error because I have a populated ListBox, when you select a file name in the ListBox the contents of that file are then displayed in a textbox.
Now, I have a depopulate button that clears all the files from the ListBox, if a file is selected, then I get the error.
I want to be able to click the depopulate button and clear both boxes.
The code:
private void DE_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
myScaleTransform2.ScaleX = myScaleTransform2.ScaleX * .9833333333333333333333333333333333333333333333333333333333;
myScaleTransform2.ScaleY = myScaleTransform2.ScaleY * .9833333333333333333333333333333333333333333333333333333333;
lbz.Items.Clear();
}
private void lbz_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
tb1.Text = File.ReadAllText(lbz.SelectedItem.ToString());
}
Please check weather your list item contain file path or not?