Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
XamCarouselPanel via a touch screen
posted

Hello,

I use the XamlCarouselPanel as the first window of my WPF application. It works perfectly.
Only now, I want to interact via touch screen.
The XamlCarouselPanel is composed of several images. How can I influence the direction of the carousel according to the movement of the finger on the screen: either scroll through the images from left to right or from right to left.
 

  • How change the FlowDirection "LeftToRight" or "RightToLeft"
  • or via an event and choose :

XamCarouselPanel1.ExecuteCommand (XamCarouselPanelCommands.NavigateToPreviousItem) or XamCarouselPanel1.ExecuteCommand (XamCarouselPanelCommands.NavigateToNextItem);

I do not see what is the right way and how? how to capture the direction of movement of the finger?
Here is my code:

<my:XamCarouselPanel x:Name="XamCarouselPanel1" Hyperlink.RequestNavigate="XamCarouselPanel1_RequestNavigate" TouchMove="XamCarouselPanel1_TouchMove"  >
            <my:XamCarouselPanel.ViewSettings>
                <my:CarouselViewSettings
          ItemsPerPage="7"
          IsListContinuous="True"
          ItemPathPadding="0,0,0,120"
          ItemSize="150,120"
          ItemPathHorizontalAlignment="Stretch"
          ItemPathVerticalAlignment="Stretch" IsNavigatorVisible="False">
                    <my:CarouselViewSettings.ItemPathRenderPen>
                        <Pen Brush="Black" Thickness="0"/>
                    </my:CarouselViewSettings.ItemPathRenderPen>
                    <my:CarouselViewSettings.ItemPathRenderBrush>
                        <RadialGradientBrush>
                            <GradientStop Color="#4CE2E0E0" Offset="0"/>
                            <GradientStop Color="#FFEDEBF5" Offset="0.15"/>
                            <GradientStop Color="#4CD6D1D1" Offset="0.30"/>
                            <GradientStop Color="#FFEDEBF5" Offset="0.45"/>
                            <GradientStop Color="#4CD6D1D1" Offset="0.60"/>
                            <GradientStop Color="#FFEDEBF5" Offset="0.75"/>
                            <GradientStop Color="#4CDED8D8" Offset="1"/>
                        </RadialGradientBrush>
                    </my:CarouselViewSettings.ItemPathRenderBrush>
                </my:CarouselViewSettings>
            </my:XamCarouselPanel.ViewSettings>
            <TextBlock><Hyperlink NavigateUri="alertes" Focusable="False"><Image Width="80" Height="80" Source="Images/Alertes.gif"/></Hyperlink></TextBlock>
            <TextBlock><Hyperlink NavigateUri="srv" Focusable="False"><Image Width="80" Height="80" Source="Images/srv.png"/></Hyperlink></TextBlock>
            <TextBlock><Hyperlink NavigateUri="indicateurs" Focusable="False"><Image Width="80" Height="80" Source="Images/Indicateurs.png"/></Hyperlink></TextBlock>
        </my:XamCarouselPanel>       

and in c# :

private void XamCarouselPanel1_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            RequestNavigateEventArgs rn = e as RequestNavigateEventArgs;
            string uri = rn.Uri.ToString();
            //System.Diagnostics.Process.Start(uri);
            switch (uri)
            {
                case "alertes":
                    {
                        if (this.OwnedWindows.Count == 0)
                        {
                            Window browserMichel = new Windows.BrowserAlertes();
                            browserMichel.Owner = this;
                            browserMichel.Show();
                            this.Hide();
                        }
                        break;
                    }
                case "srv":
                    {
                        if (this.OwnedWindows.Count==0)
                        {
                        Window scom = new Windows.Scom();
                        scom.Owner=this;
                        scom.Show();
                        this.Hide();
                        }                       
                        break;
                    }

                case "indicateurs":
                    {
                        //_mainFrame.NavigationService.Navigate(new Pages.Page2());
                        break;
                    }
            }                                  
            e.Handled = true;
        }

        private void XamCarouselPanel1_TouchMove(object sender, TouchEventArgs e)
        {
            XamCarouselPanel1.ExecuteCommand(XamCarouselPanelCommands.NavigateToPreviousItem);
        }


Thank you
Didier

 

Parents Reply Children
No Data