LockablePivot抛出InvalidCastException

时间:2012-03-16 03:46:03

标签: c# windows-phone-7 windows-phone-7.1

我正在尝试实现Windows Phone Toolkit中的lockablePivot控件 - 2011年8月(7.1 SDK)版本。

每次在运行时更改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;
    }

1 个答案:

答案 0 :(得分:1)

该错误有一张开放票。见http://silverlight.codeplex.com/workitem/10793。请不要忘记投票。