If I try to do that, I get \"System.Windows.Markup.XamlParseException\".
My XAML code looks like this:
Additional information from exception is: Two-way binding requires Path or XPath.
TextBox Text property has TwoWay binding mode by default. TwoWay bindings do not accept empty bindings like "{Binding}". Try the following.
I think, changing your collection type and using some custom type instead of string will be a better solution though: XAML:
Code-behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new MainViewModel();
}
}
public class MainViewModel
{
public ObservableCollection ErrorLog { get; set; } = new ObservableCollection
{
new Error("A"),
new Error("B"),
};
}
public class Error
{
public Error(string message)
{
Message = message;
}
public string Message { get; set; }
}
Also consider implement INotifyPropertyChanged interface to be able to change message from view model if needed.