【问题标题】:Disable pivot flick for WP7禁用 WP7 的枢轴轻弹
【发布时间】:2011-05-15 13:35:51
【问题描述】:

看到这篇博文:http://mine.tuxfamily.org/?p=111,我试图在轻弹枢轴内的控件时禁用枢轴轻弹。

我已经用 IsHitTestVisible 尝试了建议的解决方案,但似乎在将其设置为 false 时应用程序会锁定。

要重现该问题,请创建一个 wp7 基本应用程序。使用这个 xaml :

<Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid x:Name="ContentPanel" Margin="12,0,12,0">
            <controls:Pivot Name="pivotCtrl" Grid.Row="1">
                <controls:Pivot.HeaderTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Value1}"/>
                    </DataTemplate>
                </controls:Pivot.HeaderTemplate>
                <controls:Pivot.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="40"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <TextBlock Grid.Row="0" Height="38" HorizontalAlignment="Left" VerticalAlignment="Top" Width="200" Text="{Binding Value1}" />
                            <TextBlock Grid.Row="1" Height="38" HorizontalAlignment="Left" VerticalAlignment="Top" Width="200" Text="{Binding Value2}" />
                            <Canvas Grid.Row="2" Width="400" Height="300" Background="Yellow" MouseLeftButtonUp="Canvas_MouseLeftButtonUp" MouseLeftButtonDown="Canvas_MouseLeftButtonDown" />
                        </Grid>
                    </DataTemplate>
                </controls:Pivot.ItemTemplate>
            </controls:Pivot>
        </Grid>
    </Grid>

使用此代码:

public partial class MainPage : PhoneApplicationPage
{
    // Constructor
    public MainPage()
    {
        InitializeComponent();

        List<Element> elements = new List<Element>();
        for (int i = 0 ; i < 10 ; i++)
            elements.Add(new Element { Value1 = "Value - " + i, Value2 = "Something - " + i});

        pivotCtrl.ItemsSource = elements;
    }

    private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        Debug.WriteLine("On");
        pivotCtrl.IsHitTestVisible = true;
    }

    private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        Debug.WriteLine("Off");
        pivotCtrl.IsHitTestVisible = false;
    }
}

public class Element
{
    public string Value1 { get; set; }
    public string Value2 { get; set; }
}

在调试模式下,我可以看到“关闭”值,但看不到“开启”值。

也许有另一种解决方案。

提前感谢您的帮助。

【问题讨论】:

    标签: windows silverlight windows-phone-7


    【解决方案1】:

    此解决方案已于本周发布。它对你更有效吗?

    Preventing the Pivot or Panorama controls from scrolling

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-26
      • 1970-01-01
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-18
      相关资源
      最近更新 更多