2012-03-18 75 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