Hi,
I have a data grid with UserSortMode set to "Single".
If i use my columns as DataGridTextColumn every thing works as expected.
If I modify my column as DataGridTempateColumn and Specify SortDescriptor as "DelegateSortDescriptor", Data is sorted as expected, but the sort icon in column header remains as is.
Please find the code snippet below.
Steps to regenerate
Note that Name column is sorted, but notice that the sort icon on "Id" column is retained, which is not expected.
Please have a look at the issue and point me if i am missing any thing.
Code Snippet
>>>>>>>>>>>>
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:telerik="clr-namespace:Telerik.XamarinForms.DataGrid;assembly=Telerik.XamarinForms.DataGrid"
xmlns:local="clr-namespace:GridSorting"
x:Class="GridSorting.Views.MainPage"
Title="{Binding Title}">
<StackLayout>
<telerik:RadDataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False" SelectionMode="Single" UserSortMode="Single">
<telerik:RadDataGrid.SelectionStyle>
<telerik:DataGridBorderStyle BackgroundColor="LightGoldenrodYellow" BorderColor="DarkBlue"/>
</telerik:RadDataGrid.SelectionStyle>
<telerik:RadDataGrid.Columns>
<!--<telerik:DataGridNumericalColumn PropertyName="Id" HeaderText="ID"/>-->
<telerik:DataGridTemplateColumn HeaderText="ID">
<telerik:DataGridTemplateColumn.SortDescriptor>
<local:MySortDescriptor PropertyName="Id" />
</telerik:DataGridTemplateColumn.SortDescriptor>
<telerik:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate>
<Grid Padding="10">
<Label Text="{Binding Id}"/>
</Grid>
</DataTemplate>
</telerik:DataGridTemplateColumn.CellContentTemplate>
</telerik:DataGridTemplateColumn>
<!--<telerik:DataGridTextColumn PropertyName="Name" HeaderText="Name"/>-->
<telerik:DataGridTemplateColumn HeaderText="Name">
<telerik:DataGridTemplateColumn.SortDescriptor>
<local:MySortDescriptor PropertyName="Name" />
</telerik:DataGridTemplateColumn.SortDescriptor>
<telerik:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate>
<Grid Padding="10">
<Label Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</telerik:DataGridTemplateColumn.CellContentTemplate>
</telerik:DataGridTemplateColumn>
<!--<telerik:DataGridTextColumn PropertyName="City" HeaderText="City"/>-->
<telerik:DataGridTemplateColumn HeaderText="City">
<telerik:DataGridTemplateColumn.SortDescriptor>
<local:MySortDescriptor PropertyName="City" />
</telerik:DataGridTemplateColumn.SortDescriptor>
<telerik:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate>
<Grid Padding="10">
<Label Text="{Binding City}"/>
</Grid>
</DataTemplate>
</telerik:DataGridTemplateColumn.CellContentTemplate>
</telerik:DataGridTemplateColumn>
</telerik:RadDataGrid.Columns>
</telerik:RadDataGrid>
</StackLayout>
</ContentPage>
namespace GridSorting
{
public class MySortDescriptor : DelegateSortDescriptor
{
public MySortDescriptor()
{
KeyLookup = new MyKeyLookUp(this);
Comparer = new MyComparer();
}
public string PropertyName { get; set; }
}
public class MyKeyLookUp : IKeyLookup
{
private MySortDescriptor mySortDescriptor;
public MyKeyLookUp(MySortDescriptor mySortDescriptor)
{
this.mySortDescriptor = mySortDescriptor;
}
public object GetKey(object instance)
{
var objectAccessor = ObjectAccessor.Create(instance);
return objectAccessor[mySortDescriptor.PropertyName];
}
}
public class MyComparer : IComparer
{
public int Compare(object x, object y)
{
return string.Compare(x.ToString(), y.ToString());
}
}
}
namespace GridSorting.ViewModels
{
public class MainPageViewModel : ViewModelBase
{
private ObservableCollection<MainPageModel> _items;
public MainPageViewModel(INavigationService navigationService)
: base(navigationService)
{
Title = "Main Page";
Items = new ObservableCollection<MainPageModel>(new List<MainPageModel>()
{
new MainPageModel() { Id = 1, Name = "Name 1", City = "City 1" },
new MainPageModel() { Id = 2, Name = "Name 2", City = "City 2" },
new MainPageModel() { Id = 3, Name = "Name 3", City = "City 3" },
new MainPageModel() { Id = 4, Name = "Name 4", City = "City 4" },
new MainPageModel() { Id = 5, Name = "Name 5", City = "City 5" },
new MainPageModel() { Id = 6, Name = "Name 6", City = "City 6" },
new MainPageModel() { Id = 7, Name = "Name 7", City = "City 7" },
new MainPageModel() { Id = 8, Name = "Name 8", City = "City 8" },
new MainPageModel() { Id = 9, Name = "Name 9", City = "City 9" },
new MainPageModel() { Id = 10, Name = "Name 10", City = "City 10" },
});
}
public ObservableCollection<MainPageModel> Items
{
get { return _items; }
set { SetProperty(ref _items, value); }
}
}
public class MainPageModel
{
public int Id { get; set; }
public string Name { get; set; }
public string City { get; set; }
}
}
<<<<<<<<<<<<
Thank you.
Hi,
I'm using several Telerik controls in my Xamarin.Forms app, like RadListView, RadButton, RadExpander etc. The issue I'm facing is when I scroll RadListView, the app crashes with following exception:
"Scrapped or attached views may not be recycled. isScrap:false isAttached:true xamarin.forms"
I tried searching a lot about this issue but there are only native solutions available, and there is no native code used in Xamarin.Forms project. I'm unable to find any solution for this crash on any Xamarin Forum or blog.
It would be really appreciable if someone can look into this issue and guide me what am I doing wrong?
Thanks & Regards,
Nidhi Sood
Is there a way to detect killing the app by the user. If user kills an app from recent apps.
Thanks in advance.
Hi,
Just two questions:
- Is it possible to click on WEB link inside PDF ?
- Whan you zoom in, quality decreases (blur effect), is it normal ? It is not vectorial ?
If not, is it planned to add it ?
Thank you
I need to change the color of a RadButton highlight when it's pressed. It's currently a Grey and I need it to be white. I understand theming, but can't find any documentation on what Color x:key values can be set for the RadButton.
Any help will be greatly appreciated.
Hi,
We have just upgraded to Xamarin Forms 4 and the page containing the Conversational UI throws the following exception when the user backs out to the previous page;
Unhandled managed exception:
Object reference not set to an instance of an object
(System.NullReferenceException)
at
Telerik.XamarinForms.DataControlsRenderer.iOS.ItemsControlRenderer.OnElementChanged
(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
[0x00036] in <
8e5a228dc72e438d99c2a75ee9177c40
>:0
at
Telerik.XamarinForms.ConversationalUIRenderer.iOS.ChatListViewRenderer.OnElementChanged
(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
[0x00000] in <
0ae6311f3c4d4a12931b84110a04104e
>:0
at
Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement
(TElement element) [0x0012a] in <
db147fad2aa9412c845ff0ead92dfe20
>:0
at
Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Dispose
(System.Boolean disposing) [0x0008c] in
<
db147fad2aa9412c845ff0ead92dfe20
>:0
at
Xamarin.Forms.Platform.iOS.ViewRenderer`2[TView,TNativeView].Dispose
(System.Boolean disposing) [0x0005c] in
<
db147fad2aa9412c845ff0ead92dfe20
>:0
at Foundation.NSObject.Dispose<…>
This doesn't appear to happen on Android (which makes sense as the stack trace runs off into the iOS specific renderer) and happens simply with the presence of the chat control on the page, even when things like the ItemsSource and ItemTemplateSelector are not configured meaning no items are being displayed in the control.
Any help would be much appreciated.
regards,
Is there a way to set radlistview row height to fit to the content. Here how I set the radListview.
<
telerikDataControls:RadListView
x:Name
=
"listView"
ItemsSource
=
"{Binding Source={StaticResource Labels}, Path=Obj}"
>
<
telerikDataControls:RadListView.ItemTemplate
>
<
DataTemplate
>
<
telerikListView:ListViewTemplateCell
>
<
telerikListView:ListViewTemplateCell.View
>
<
StackLayout
>
<
template:AppointmentListItemTemplate
/>
</
StackLayout
>
</
telerikListView:ListViewTemplateCell.View
>
</
telerikListView:ListViewTemplateCell
>
</
DataTemplate
>
</
telerikDataControls:RadListView.ItemTemplate
>
</
telerikDataControls:RadListView
>