2
我想在我的Windows Phone(7.1)應用程序中創建一個「TreeView-like」顯示。
爲了做到這一點,我使用Silverlight Toolkit中的「ExpanderView」。Windows Phone ExpanderView - 「參數不正確。」
所以基本上,我的程序添加ExpanderViews內ExpanderViews爲了創建樹。
一切都是fin直到一個元素水平超出屏幕,它給了我一個例外「參數不正確。」在以下代碼中的「Debugger.Break()」行上:
// 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();
}
}
在App.xaml.cs.下。
我假設該元素不會初始化/加載corrently,因爲我有這個異常之前與相同的元素,我添加的項目沒有完全加載父元素。
這是我的XAML:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid x:Name="ContentPanel" Margin="12,0,12,0"/>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/Plus.png" Text="Add" Click="ApplicationBarIconButtonClick"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
這是後面的代碼:
public MainPage()
{
InitializeComponent();
_lastView = new ExpanderView { Header = "Header", IsExpanded = true };
ContentPanel.Children.Add(_lastView);
}
private ExpanderView _lastView;
private void ApplicationBarIconButtonClick(object sender, System.EventArgs e)
{
var newItem = new ExpanderView {Header = "Header", IsExpanded = true};
_lastView.Items.Add(newItem);
_lastView = newItem;
}
在那次之後我點擊應用程序欄按鈕(如果下一個元素水平超出屏幕) ,它給我的例外:
有什麼異常?它會發生什麼? – 2012-02-13 08:56:08
我在我的問題的第二段中提到過。 – 2012-02-13 09:46:34