locked
Slider PointerPressed and PointerReleased events not getting call RRS feed

  • Question

  • Hi All,

      I have the following code 

    <Page
        x:Class="SliderEventDemo.BlankPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:SliderEventDemo"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">

        <Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
            <Slider x:Name="SizeSlider" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Maximum="15" Minimum="5" Width="230" Margin="0,3,0,-3" />
        </Grid>
    </Page>

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.IO;
    using System.Linq;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;

    // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

    namespace SliderEventDemo
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class BlankPage : Page
        {
            public BlankPage()
            {
                this.InitializeComponent();
                SizeSlider.PointerPressed += SizeSlider_PointerPressed;
                SizeSlider.PointerReleased += SizeSlider_PointerReleased;
            }

            void SizeSlider_PointerReleased(object sender, PointerEventArgs e)
            {
    int x = 8;
            }

            void SizeSlider_PointerPressed(object sender, PointerEventArgs e)
            {
               int x = 8;
            }

            /// <summary>
            /// Invoked when this page is about to be displayed in a Frame.
            /// </summary>
            /// <param name="e">Event data that describes how this page was reached.  The Parameter
            /// property is typically used to configure the page.</param>
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
            }       
        }
    }

    I Have register the PointerPressed and PointerReleased events for the slider in .cs code

    but when i am pressing pointer down the control is not coming inside the SizeSlider_PointerPressed function

    Thanks in advance 

    Ashish

    Tuesday, April 17, 2012 9:17 AM

Answers

  • It seems like these events are indeed swallowed by the slider's child components. I suggest you set the ManipulationMode of the slider to "TranslateRailsX", and then use the ManipulationStarted and ManipulationCompleted events instead of PointerPressed and PointerReleased.
    • Marked as answer by Min ZhuMember Monday, April 30, 2012 9:28 AM
    Tuesday, April 17, 2012 8:24 PM

All replies

  • It seems like these events are indeed swallowed by the slider's child components. I suggest you set the ManipulationMode of the slider to "TranslateRailsX", and then use the ManipulationStarted and ManipulationCompleted events instead of PointerPressed and PointerReleased.
    • Marked as answer by Min ZhuMember Monday, April 30, 2012 9:28 AM
    Tuesday, April 17, 2012 8:24 PM
  • Diederick, the workaround is only partially working. If you just click on the slider, the Manipulation does not start.

    The good news are that on the Windows 8.1 the problem seems to be resolved (I think the 4.5.1 version of the framework contains an updated version of the slider component).

    Friday, July 12, 2013 6:08 AM