2013-01-21 29 views
1

我需要的是在项目框的边距设置为10的设计师抛出NullReference异常

设计器视图保持抛出异常,所以我不能继续。

<phone:Pivot.ItemTemplate> 
    <DataTemplate> 
     <phone:PivotItem Margin="10"/> 
    </DataTemplate> 
</phone:Pivot.ItemTemplate> 

这段代码有什么问题?

回答

0

对不起,我没有意识到这是WP8。在WP8上,电话 Pivots的默认名称空间。虽然这是相当随意的。你确定问题不在其他地方吗?它仍然将是有益的为你分担你的XAML,但这里是一些对我的作品:

<phone:Pivot> 
    <phone:Pivot.ItemTemplate> 
     <DataTemplate> 
      <phone:PivotItem Margin="10"> 
       <Grid> 
        <!--Contents of template--> 
       </Grid> 
      </phone:PivotItem> 
     </DataTemplate> 
    </phone:Pivot.ItemTemplate> 
    <phone:PivotItem Header="Hello"> 
     <Grid> 
      <!--Contents of "Hello" item--> 
     </Grid> 
    </phone:PivotItem> 
    <phone:PivotItem Header="World"> 
     <Grid> 
      <!--Contents of "World" item--> 
     </Grid> 
    </phone:PivotItem> 
</phone:Pivot> 
+0

是,命名空间似乎是手机对我来说。但我真的很想要一个模板,因为我需要在脚本中动态添加它们。然而,你的脚本(第二个)没有为我工作,因为它仍然给出一个空例外 – user1510539

+0

这是非常奇特的......它在我完全空白的项目中工作得很好。 – mirichan

+0

您是手动编写所有xaml文件,还是在页面上放置一个Pivot,然后在xaml中编辑它?另外,你的目标是什么版本的Windows Phone? 7.0/7.1/8.0? – mirichan