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.
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 youDidier
Hi,
I hadn’t heard back from you. I was wondering if I could be of any further assistance.
Looks like you have already discovered the xamCarousel’s commands that will NavigateToPreviousItem or NavigateToNextItem.
The xamCarouselPanel inherits touch events from System.Windows.UIElement so you should be able to trap these events in order to get the direction of the touch. Then you will be able to apply the appropriate direction by using the xamCarouselPanel’s PanelCommands.
This is a link to a Microsoft article on Input API and it includes a section on touch events. It may be helpful. It describes the relationship between the move and manipulation when setting isManipulatinEnabled property.
http://msdn.microsoft.com/en-us/library/ms754010.aspx
XamCarousel API
Scroll down and you will see the touch events that are available.
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=InfragisticsWPF4.v11.1~Infragistics.Windows.Controls.XamCarouselPanel_members.html
XamCarouselPanelCommands
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=InfragisticsWPF4.v11.1~Infragistics.Windows.Controls.XamCarouselPanelCommands_members.html
Please let me know if you have further questions.