Hello all together.
The problem is, that the RadDataGrids horizontal scrolling stops working on dynamically reloading the RadDataGrids ItemsSource. Horizontal srolling is no longer possible then. (I have a bit of a complex UI, where the RadDataGrid is wrapped inside a Grid inside a StackPanel, ..., but I could not find any coherence to the issue.)
What you need:
1. RadDataGrid with 1 DataGridTemplateColumn
2. ItemsSource bound to ObservableCollection in ViewModel
3. DataTemplate in Column 1 with Label to display text from binding through ItemsSource. Important: Text length to display in the Label must be wider than RadDataGrids with, to let the horizontal scollbar appear.
4. Two buttons in the view. On each button tap reassign the ObservableCollection in ViewModel with "new ObservableCollection" (see added source code).
5. Switch two or three times between Button1 and Button2 to let the ItemsSource be reassigned.
6. Try horizontal scrolling on white space in RadDataGrid. Scrollbar won't appear and scrolling won't be possible. If you set RadDataGrids SelectedItem after reassining the ItemsSource, scolling will only be possible again if you tap the selected item again.
(property ListItems is binding to RadDataGrids ItemsSource. Source code is not optimized, just from scratch to catch the point.)
private void Button1ClickCommand()
{
List<
string
> list = new List<
string
>
{
"This is a very long text for testing horizontal scrollbar issue.",
"This is a very long text for testing horizontal scrollbar issue.",
"This is a very long text for testing horizontal scrollbar issue.",
"This is a very long text for testing horizontal scrollbar issue.",
"This is a very long text for testing horizontal scrollbar issue.",
"This is a very long text for testing horizontal scrollbar issue."
};
Device.BeginInvokeOnMainThread(() => ListItems = new ObservableCollection<
string
>(list));
}
private void Button2ClickCommand()
{
List<
string
> list = new List<
string
>
{
"This is another very long text for testing horizontal scrollbar issue.",
"This is another very long text for testing horizontal scrollbar issue.",
"This is another very long text for testing horizontal scrollbar issue.",
"This is another very long text for testing horizontal scrollbar issue.",
"This is another very long text for testing horizontal scrollbar issue.",
"This is another very long text for testing horizontal scrollbar issue."
};
Device.BeginInvokeOnMainThread(() => ListItems = new ObservableCollection<
string
>(list));
}
ObservableCollection<
string
> listItems;
public ObservableCollection<
string
> ListItems
{
get
{
return listItems;
}
set
{
listItems = value;
OnPropertyChanged();
}
}
Thank you,
best regards
Martin