2012-03-18 74 views
2

我正在尝试为我的Windows Phone应用程序实现拖放界面。我正在关注这个tutorial。我从their网站下载并安装了Silverlight工具包。我还添加了对它的引用。如何使用Silverlight工具包

当我尝试编译我的代码时出现以下错误。

Error 1 'toolkit' is an undeclared prefix. Line 33, position 14. C:\Users\USER\Documents\Visual Studio 2010\Projects\DragEventDemo\DragEventDemo\MainPage.xaml 33 14 DragEventDemo 

这是我在内容网格我MainPage.xaml中的代码

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"></Grid> 
    <Rectangle Width="100" Height="100" Fill="Red"> 
     <toolkit:GestureService.GestureListener> 
      <toolkit:GestureListener DragDelta="OnDragDelta" 
     GestureBegin="OnGestureBegin" GestureCompleted="OnGestureCompleted" /> 
     </toolkit:GestureService.GestureListener> 
     <Rectangle.RenderTransform> 
      <TranslateTransform /> 
     </Rectangle.RenderTransform> 
    </Rectangle> 
</Grid> 

什么我错过了?

+2

您是否在页面中包含了Toolkit命名空间? 'xmlns:toolkit =“clr-namespace:Microsoft.Phone.Controls; assembly = Microsoft.Phone.Controls.Toolkit”' – 2012-03-18 07:23:05

回答

4

你在PhoneApplicationPage标签中有前缀声明吗?

<phone:PhoneApplicationPage 
     (...) 
     xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
     (...) 
    > 
+0

如何获得这个自动添加? – nikhil 2012-03-18 07:24:30

+0

有帮助的例外,例如。 Resharper:http://www.jetbrains.com/resharper/ – MarcinJuraszek 2012-03-18 10:36:28