クラスプロパティの1つをバインドしたい。私はFileList.DataContext = fileManager;
以下でそれを行います私はコードビハインドを置きます。
C#
public class File : ListBoxItem
{
private string name;
public string Name
{
get { return this.name; }
set { this.name = value; }
}
private string id;
public string Id
{
get { return this.id; }
set { this.id = value; }
}
}
public class FilesManager
{
public ObservableCollection<File> Files { get; set; }
public FilesManager()
{
Files = new ObservableCollection<File>();
}
}
XAML
<ListBox Name="FileList" Width="auto" Height="578" ItemsSource="{Binding Files, Mode=OneWay}" Tap="FileList_Tap" FontSize="36" Margin="0,14,0,15">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
アプリが起動すると、データが割り当てられます。その後、バインディングが正常になる前に、Application_UnhandledExceptionが発生します。私が間違っているのは何ですか?
アップデート
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
}//here debugger stops.