9 Answers, 1 is accepted
The provided code seems ok and I am not able to find what could be the reason for the erroneous behavior you've described just from it. In general, the UI Virtualization of the RadDataGrid control cannot be turned off, however, it doesn't cause such issues with horizontal scrolling at our side.
I will need more details on your setup, so I could research this further. It could be really helpful if you could send us a sample project where the issue is reproduced. Please open a support ticket and attach it there, as in the forums only image attachments are allowed.
Thank you for reply.
Can't turn it off, not a known problem.
Ok... let me look more. I'm using a inherited class, from 'Entry', and perhaps it's custom renderer is causing problems.
I'll post answer if I see what's going on. If I come up empty I'll throw an example project together, open ticket, and link here.
Upon further review... it seems just adding the DataTemplate causes the problem.
x.HeaderContentTemplate = dt;
Before I create a project, open ticket, ect. ... could I please trouble you to set
HeaderContentTemplate to a DataTemplate (just Label is fine)
with an existing project you have, that has horizontal scrolling with RadDataGrid,
to verify it's not an existing problem (if you haven't already)?
I only ask because a) should just take you a sec to verify, and b) I've read some of your doc's that suggest you should not do this at all (not in Xamarin specific doc's mind you).
I'm assuming Xamarin Forms.
Thank you for any effort you're able to put into this. I got a deadline tomorrow, so I won't be able to follow up by creating a ticket till next week.
I have tried to reproduce the issue you have reported but on my side it works fine. It would be really helpful if you can send us a video or a screenshot that shows the undesired behavior.
Please take a look at the provided project and may I ask you to modify it according to your specific scenario and send it back to us? This way we could inspect the exact setup and advice you further.
I must be expert at breaking things. Didn't take long at all and is simple to reproduce. I just added 'DataTemplate' to a 'DataGridTextColumn'. This suggests a workaround (just use 'DataGridTemplateColumn', as perhaps intended). Haven't checked 'fix' yet, wanted to help you to see behavior. Update 'StartPage.xaml' (with below code) in your project, start, scroll right/left a few times and you'll see headers out of order. I'll update after I try using 'DataGridTemplateColumn' (to see if it IS a workaround).
Used 'HeaderContentTemplate' as you can see in code below.
just put whole page for ease... just added DataTemplate to the DataGridTextColumn(s).
I have tested the provided code and I was able to reproduce the issue. It comes from the recycling visual elements in the DataGrid's header when local properties are used instead of Binding. I can suggest you to use a single template and bindings to it if you are using headers that look the same:
As another workaround, you can implement a template selector feature inside the DataTemplate, in case you want to use headers that look different.
I have logged this in our Feedback portal, you can follow the item on the provided link below:
You can also find your Telerik points updated for reporting this to us.
Binding works as you show, but when I add a second item (Entry) to the DataTemplate, that specific control get's shown In wrong column on scrolling. Tried binding it's ClassIdProperty to HeaderText, not working. When I bind to TextProperty of the Entry to HeaderText, it works... but that's not helpful in that I need user to interact with the Entry.
Do you (please!) have a suggestion/workaround that will allow me to have a second control (Entry) in the DataTemplate?
You can achieve the required approach by implementing a TemplateSelector feature inside the DataTemplate.
Some of the steps you need to do are:
- create a class(MyContentView) that inherits from the ContentView class
- create another class (MyTemplateSelector) that inherits from the DataTemplateSelector class and inside this class use the OnSelectTemplate method to implement your logic which template to be returned.
- you need to add DataTemplare and MyTemplate selector as a resources in the Resource page of the app.
- in MyContentView class create a TemplateSelector property from type Datatemplate and in the Resources set "myTemplateSelector" as a static resource to this property.
- Inside all columns in the DataGrid set the HeaderContentTemplate to be a static resource from type DataTemplate.
For more details, please take a look at the provided example and let me know if you have any other questions on this.