I need to create the carousel in code and while i can get the control on the screen i cannot seem to configure it.
_carousel = new XamCarouselListBox(); _carousel.ViewSettings.ItemsPerPage = 3; _carousel.ViewSettings.ReserveSpaceForReflections = true; _carousel.ViewSettings.ItemSize = new Size(440, 200); _carousel.ViewSettings.IsListContinuous = true; _carousel.ViewSettings.UseOpacity = true; //_carousel.ViewSettings.UseZOrder = true; _carousel.ViewSettings.ItemPath = SwipeAndShowPath;
this code creates the control and displays the objects but will not for instance set the items/page nor the path. I am at a loss as to what i am doing wrong.
Hello Jim,
Thank you for your post. I have been looking into it and I could not manage to reproduce it. I have created a small sample for you. Would you please modify the attached sample with your functionality, in order to provide you with better support. I am looking forward to hearing from you.
ok i can see your example works and with a little playing it is because the carousel is created in xaml if you comment that out and make the code behind like so it does not work
DataContext = CarBusinessLogic.GetCars(); XamCarouselListBox _carousel = new XamCarouselListBox(); InitializeComponent(); _carousel.ViewSettings.ItemsPerPage = 3; _carousel.ViewSettings.ReserveSpaceForReflections = true; _carousel.ViewSettings.ItemSize = new Size(440, 200); _carousel.ViewSettings.IsListContinuous = true; _carousel.ViewSettings.UseOpacity = true; _carousel.ViewSettings.ItemPath = customPath; _carousel.DisplayMemberPath = "Model"; _carousel.ItemsSource = CarBusinessLogic.GetCars(); //Grid.SetRow(_carousel, 0); //Grid.SetColumn(_carousel, 0); _grid.Children.Add(_carousel); }
The grid displays but the settings are the default settings. Could it be that the grid needs to initialize before these setting can be set?
that appears to be it, if i move the initialization code to loaded it now works.
I am glad that my approach was helpful to you. Please do not hesitate to contact us if you have any further questions.