2012-03-16 44 views
3

我試圖實現在Windows Phone Toolkit - 2011年8月(7.1 SDK)發行版中找到的lockablePivot控件。LockablePivot拋出InvalidCastException

當我在運行期間每次更改isLocked屬性時都向控件添加itemtemplate時,它會引發InvalidCastException。是否有任何解決方法?

需要幫助。由於


<Grid x:Name="LayoutRoot" Background="Transparent"> 

    <toolkit:LockablePivot Name="Pages" SelectionChanged="Pivot_Changed" ItemsSource="{Binding}">   

     <toolkit:LockablePivot.ItemTemplate> 
       <DataTemplate> 
       <Grid VerticalAlignment="Stretch"> 
        <Button Content="Lock" Click="Button_Click"/> 

        <Image Stretch="Uniform" local:WP7ImageZoomer.IsZoomingEnabled="True" ManipulationStarted="Image_ManipulationStarted" ManipulationCompleted="Image_ManipulationCompleted" ManipulationDelta="Image_ManipulationDelta" CacheMode="BitmapCache"> 
         <Image.Source> 
          <BitmapImage x:Name="Bit" UriSource="{Binding Img}" DownloadProgress="BitmapImage_DownloadProgress" CreateOptions="BackgroundCreation"/> 
         </Image.Source> 
        </Image> 
       </Grid> 

      </DataTemplate> 
     </toolkit:LockablePivot.ItemTemplate> 
    </toolkit:LockablePivot> 
</Grid> 

C#:

private void Image_ManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e) 
    { 

     this.Pages.IsLocked = true;// Throws InvalidCastException here 
    } 

    private void Image_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e) 
    { 
     this.Pages.IsLocked = false; 
    } 

    private void Image_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) 
    { 
     //this.Pages.IsLocked = true; 
    } 
+0

請顯示您的代碼。不要只是描述它。 http://stackoverflow.com/questions/how-to-ask – 2012-03-16 19:18:16

回答

相關問題