Telerik Forums
UI for Xamarin Forum
2 answers
124 views

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

  • Open the application
  • Sort "Id" Column (Ascending)
  • Immediately sort "Name" column 

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.

Safan
Top achievements
Rank 1
 answered on 27 Jun 2019
4 answers
155 views
I have implemented swipe to delete functionality using the RadListView. When you swipe to the left it reveals the underlying delete button, using the Telerik examples provided. On iOS it behaves exactly like I would expect. I can only swipe in one direction. However, on Android, you can swipe in both directions and make the cell move. How can I prevent swiping to the right on Android, while still allowing swipe to the left for deleting rows?
Pavel R. Pavlov
Telerik team
 answered on 27 Jun 2019
7 answers
295 views

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

Marginpoint
Top achievements
Rank 1
 answered on 27 Jun 2019
1 answer
573 views

Is there a way to detect killing the app by the user. If user kills an app from recent apps. 

Thanks in advance.

Lance | Senior Manager Technical Support
Telerik team
 answered on 25 Jun 2019
1 answer
139 views
When I display any file in the RadPdfViewer (on iOS, Android, UWP) using either a byte array or file source, when I scroll page the first page and then come back, the first page never re-displays. All the other pages do, but the first page just displays a white rectangle. I have also tried both layout modes and they exhibit the same behavior.
Petar Marchev
Telerik team
 answered on 25 Jun 2019
1 answer
221 views

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

Petar Marchev
Telerik team
 answered on 25 Jun 2019
1 answer
219 views
Hi there,
I want to make my app white list for BatteryOptimization in smart manager application. I noticed that some application i.e. "WhatsApp", "Messenger" , "Viber" "imo" etc white listed bydefault.
When ever we install these application bydefault these application's "Power saving" is turned off in "smart manager application". How can do the same with my application i.e. bydefault it's "Power saving" should be turned off in "smart manager application" ?
Lance | Senior Manager Technical Support
Telerik team
 answered on 24 Jun 2019
3 answers
562 views

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.

Lance | Senior Manager Technical Support
Telerik team
 answered on 24 Jun 2019
12 answers
269 views

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,

Lance | Senior Manager Technical Support
Telerik team
 answered on 21 Jun 2019
6 answers
1.3K+ views

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>
Lance | Senior Manager Technical Support
Telerik team
 answered on 21 Jun 2019
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?