我使用列表框中顯示的項目列表,因爲它的XAML代碼如下,麻煩的Windows Phone在列表中添加數據
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="List" HorizontalAlignment="Left" Height="612" Margin="6,7,0,0" VerticalAlignment="Top" Width="443" SelectionChanged="List_SelectionChanged_1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Width="400" Height="50">
<TextBlock x:Name="tbName" Width="400" Height="44" FontSize="22" FontWeight="Bold" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
,我只是通過下面的C#代碼填充列表,當執行
this.List.Items.Add(data);
foreach (var item in categoryDetails.Category)
{
CategoryDisplay data = new CategoryDisplay();
data.Name = item.accountName;
data.Id = item.accountID;
this.List.Items.Add(data);
}
一切順利,直到最後一步,總會有一個錯誤,說明
An exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll but was not handled in user code
可能是什麼問題?我應該怎麼做才能糾正它?
我已經改變了錯誤味精,請看看它 – Aju