开发者

Disable pivot flick for WP7

开发者 https://www.devze.com 2023-01-26 16:59 出处:网络
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.

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.

I've tryed the proposed solution with IsHitTestVisible, but it seems that the application locks when setting it to false.

To reproduce the problem, create a wp7 basic application. Use this 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}"开发者_如何学Python />
                            <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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号