I have a requirement to refresh the carousel control every minute with data. I am using a custom entity to populate the carousel with data and have defined a data template for the same.
I have managed to refresh the carousel - however, after refresh the same item should be at the centre of the carousel as before the refresh. I am using the below code to do the bring the item into view, but it doesnt seem to work.
Record objRec = rdcTasks.SelectedRecord;
RadCarouselPanel panel = this.rdcTasks.FindCarouselPanel();
this.rdcTasks.ItemsSource = this.CreateItemSource();
In debug mode when I check the value of objRec, it shows the correct data record. However, it does not bring it to the centre.
Also, I need to set a different colour for the data record at the centre of the carousel. How can I achieve this?
Thanks in advance.
5 Answers, 1 is accepted
|The enumeration value is 0. Operations are not processed.|
|The enumeration value is 1. Operations are processed when the system is idle.|
|The enumeration value is 2. Operations are processed when the application is idle.|
|The enumeration value is 3. Operations are processed after background operations have completed.|
|The enumeration value is 4. Operations are processed after all other non-idle operations are completed.|
|The enumeration value is 5. Operations are processed at the same priority as input.|
|The enumeration value is 6. Operations are processed when layout and render has finished but just before items at input priority are serviced. Specifically this is used when raising the Loaded event.|
|The enumeration value is 7. Operations processed at the same priority as rendering.|
|The enumeration value is 8. Operations are processed at the same priority as data binding.|
|The enumeration value is 9. Operations are processed at normal priority. This is the typical application priority.|
|The enumeration value is 10. Operations are processed before other asynchronous operations. This is the highest priority.|
I'm not sure that this will work for you but it worked for me in another area that sounds similar. Basically, you can use a delegate to set the DispatcherPriority making your BringIntoView method more important. You probably can't use a SimpleDelegate because you are passing it a parameter. This link shows how to pass a parameter.
To get my TextBox.Focus() event to work in every situation, I had to set the DispatcherPriority to the "Input" level.
It seems that if the item you are trying to bring into view is out of the "viewport" it doesn't work -- if it is "visible" (although not the foremost item), it does work...
When you rebind the carousel all records are recreated - new instances are created. When you try to bring into view the previsously selected record (which is no longer a part of the new record collection) the record cannot be found in the new record collection and thus it cannot be navigated to.
A better aproach is to determine the selectedIndex before you rebind and after that use that index to navigate after the carousel is rebound.
Here is a snippet tha should work for your scenario:
the Telerik team
As I mentioned in my original post, I also need to be able to set a different colour for the item that has been selected in the carousel. Could you please advise on how I can achieve this?
Thanks in advance.
To do that you will have to create new template for CarouselItem and use triggers to change the background color when the IsSelected property changes. I have prepared a sample application that demonstrates how this can be done.
What kind of criteria would you like to check for? Will you check for certain proverty values of your data objects?
For our next release we will try to redo our default styles and templates so that simple modification like that could be make without redefining the whole template.
the Telerik team