Hi,
I need to be able to double click on a carousel item however it needs to follow the mvvm pattern.
Thanks, Grant
Hi Grant,
A Behavior<T> is probably your best option. You can create a Behavior<T> where T is the XamCarousel. Inside the behavior you can handle the PreviewMouseDoubleClick event on the XamCarousel and perform whatever logic you need. If you need something executed in your view model you can add an ICommand to the behavior as a DependencyProperty and then manually execute it when the double click occurs, passing whatever information along that is required. Then when you create the behavior you can bind to a command in the view model.
(I tried searching for an MSDN article that shows an example Behavior<T> but I can't find anything so here is a pretty good example that shows how to code a Behavior and use it on a control in XAML.)
In the double click event you'll want to make sure that the mouse is contained inside a DataRecordPresenter before continuing with your logic. DataRecordPresenter is the UI element which defines a carousel item. Inside the Infragistics.Windows namespace there is a class called Utilities. This class contains a bunch of static helper methods and one of them lets you traverse the visual tree a bit easier than using the VisualTreeHelper. Use the method called GetAncestorFromType() in order to find out if the user double clicked inside a DataRecordPresenter.
var record = Infragistics.Windows.Utilities.GetAncestorFromType(e.OriginalSource as DependencyObject, typeof(DataRecordPresenter), false);if (record != null){ // user double clicked on a carousel item}
Let me know if you have any questions.
Thanks for the reply, I did just look into doing this but I think I'm creating more work for myself. The issue comes down to the fact that I cannot seem to keep my two UI lists in sync. So let me explain what it is, I have a TreeView on the right hand side of the application and a carousel on the left. Both have hierarchical data and both should be kept in sync as they are sharing the selected item property. However if the treeview it expanded to the lowest child then the carousel cannot select the correct item.
The user needs to be able to navigate through the list using the treeview and the carousel.
Also if the treeview selects the root node after the lowest child has been selected the carousel cannot handle this either, I appreciate this may be confusing so I'll upload a sample project, Hopefully there's a way around this.
I've been stuck on it for the past couple of days, please help
I can see the syncing issue you described in your sample project. It seems to be caused by jumping between more than 1 level at a time as it seems like the XamDataCarousel can only change hierarchy depth 1 level at a time. I'm checking to see if there is a way to jump to a specific hierarchy level. I'll let you know shortly.
Yeah that's exactly the problem, thanks for investigating. Let me know the outcome once you looked into it
Many thanks,
Grant
I can't find a built in way to do this so I reached out to the carousel developers to see if they have any ideas. Will let you know what they say.
Great, thanks! I have no more issues
Thanks for your help
Actually that would be expected. When you change the Theme on the control we're just adding a bunch of resources to the control level. One of these resources is a style for the CarouselBreadcrumb control. So since this style is lower in the tree (closer to the carousel control) than the one I declared in my sample, it will be used instead. To fix that you need to add the style to the XamDataCarousel.Resources. This will place the style lower in the tree making it the one that is used by the CarouselBreadcrumb.
<igDP:XamDataCarousel DataSource="{Binding Source={StaticResource dataUtil}, Path=CategoriesAndProducts}" Theme="Aero"> <igDP:XamDataCarousel.Resources> <Style TargetType="{x:Type igDP:CarouselBreadcrumb}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="{Binding Converter={StaticResource converter}}"/> </DataTemplate> </Setter.Value> </Setter> </Style> </igDP:XamDataCarousel.Resources> </igDP:XamDataCarousel>
Thanks for the example. this was actually the very first thing I tried and it didn't work for me. It works in the sample project you sent me however it does not work in my project. I am definitely using the same version of infragistics in my projects. I have even moved across my carousel control onto your sample project and it works.
It has been very frustrating but I have finally seen what the issue was. I was specifying the theme of the carousel as "Aero" in fact I have a combo box where the user can pick their theme and only certain themes work when trying to set the carousel breadcrumb content template. Very weird, unless the items you specify are "Default" or "PrintBasic" then it will not work. So in the example you sent me if you add this then you'll see:
<igDP:XamDataCarousel DataSource="{Binding Source={StaticResource dataUtil},
Path=CategoriesAndProducts}" Theme="Aero" />
Hopefully this can be fixed soon
Looking at the CarouselBreadcrumb control, we're just setting the Content property of this control to a DataRecord. The ToString() on a DataRecord is what shows the text you see. Since we're setting the Content you should be able to provide your own ContentTemplate to change the view. The DataContext for that template will be the CarouselBreadcrumb.Content which is that DataRecord. From there you can use a converter to configure the text however you like. Take a look at the example I attached.
Okay thanks for the answer, wasnt the answer I was hoping for but I can work around it. Another question I have is the breadcrumbs, I can't seem to get the DataRecord word removed from my breadcrumb navigation, I've tried many things but can't seem to get it to work.
It follows on from this post: http://ko.infragistics.com/community/forums/t/27475.aspx
Any ideas on this?