简体   繁体   English

禁用WP7的支点滑动

[英]Disable pivot flick for WP7

seeing this blog post : http://mine.tuxfamily.org/?p=111 , I'm trying to disable the pivot flick when flicking on a control inside the pivot. 看到此博客文章: http ://mine.tuxfamily.org/?p=111,我想在轻拂枢轴内部的控件时禁用枢轴轻拂。

I've tryed the proposed solution with IsHitTestVisible, but it seems that the application locks when setting it to false. 我已经使用IsHitTestVisible尝试了建议的解决方案,但似乎将其设置为false时,应用程序会锁定。

To reproduce the problem, create a wp7 basic application. 要重现该问题,请创建一个wp7基本应用程序。 Use this xaml : 使用这个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>

with this code behing : 与此代码行为:

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; }
}

In debug mode, I can see the "Off" value, but never the "On" one. 在调试模式下,我可以看到“ Off”值,但是看不到“ On”值。

Maybe there's another solution for this. 也许对此还有另一种解决方案。

Thanks in advance for your help. 在此先感谢您的帮助。

This solution was posted this week. 此解决方案已于本周发布。 Does it work better for you? 它对您更好吗?

Preventing the Pivot or Panorama controls from scrolling 防止枢轴或全景控件滚动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM