Intersoft ClientUI Documentation
SortDescriptors Property (UXDataComboBox)



Gets or sets the descriptor object that encapsulates the sorting related information.
Syntax
<CategoryAttribute("Common Properties")>
Public Property SortDescriptors As SortDescriptorCollection
Dim instance As UXDataComboBox
Dim value As SortDescriptorCollection
 
instance.SortDescriptors = value
 
value = instance.SortDescriptors
[CategoryAttribute("Common Properties")]
public SortDescriptorCollection SortDescriptors {get; set;}
[CategoryAttribute("Common Properties")]
public:
property SortDescriptorCollection^ SortDescriptors {
   SortDescriptorCollection^ get();
   void set (    SortDescriptorCollection^ value);
}
Remarks

UXPageableComboBox columns also comes with sorting capability. This feature can be enabled by set the CanUserSort property to True. You only need to bind the SortDescriptors in the XAML and handle the QueryChanged in your ViewModel.

Example

The following code shows how to use SortDescriptor on UXPageableComboBox.

XAML
Copy Code
<Intersoft:UXPageableComboBox SearchResult="{Binding Customers}"
        FilterDescriptors="{Binding LookUpDescriptor.FilterDescriptors, Mode=TwoWay}"
        SortDescriptors="{Binding LookUpDescriptor.SortDescriptors, Mode=TwoWay}" 
        PageDescriptor="{Binding LookUpDescriptor.PageDescriptor}"
        DisplayMemberPath="ContactName"
        StatusBarVisibility="True">        
        <Intersoft:UXPageableComboBox.DataContext>
                <ViewModels:CustomerViewModel/>

        </Intersoft:UXPageableComboBox.DataContext>                       
</Intersoft:UXPageableComboBox>
C#
Copy Code
using System;
using System.Collections;
using Intersoft.Client.Data.ComponentModel;
using Intersoft.ClientUI.Samples.DataControls.ModelServices;

namespace Intersoft.ClientUI.Samples.DataControls.ViewModels
{
        public class CustomerViewModel : ViewModelBase
        {
                #region Constructors

                public CustomerViewModel()
                {
                        this.CustomersSource = CustomersRepository.Instance;
                        this.Presenter = new MessagePresenter();
                        this.LookUpDescriptor = new QueryDescriptor();
                        
                        // Initialize Sort Descriptor
                        this.LookUpDescriptor.SuspendQueryChanged = true;
                        this.LookUpDescriptor.SortDescriptors.Add(new SortDescriptor() { PropertyName = "ContactName", Direction = ListSortDirection.Ascending });
                        this.LookUpDescriptor.SuspendQueryChanged = false;
                }
                
                #endregion
                
                #region Fields

                private IEnumerable _customers;
                private QueryDescriptor _lookUpDescriptor;
                
                #endregion
                
                #region Properties

                protected IDataRepository CustomersSource { get; set; }

                public IEnumerable Customers
                {
                        get { return this._customers; }
                        set
                        {
                                if (_customers != value)
                                {
                                        _customers = value;
                                        OnPropertyChanged("Customers");
                                }
                        }
                }

                public QueryDescriptor LookUpDescriptor
                {
                        get { return _lookUpDescriptor; }
                        set
                        {
                                if (_lookUpDescriptor != value)
                                {
                                        if (_lookUpDescriptor != null)
                                                _lookUpDescriptor.QueryChanged -= new EventHandler(OnLookUpQueryChanged);

                                        _lookUpDescriptor = value;
                                        _lookUpDescriptor.QueryChanged += new EventHandler(OnLookUpQueryChanged);

                                        OnPropertyChanged("LookUpDescriptor");
                                }
                        }
                }

                protected virtual MessagePresenter Presenter { get; private set; }

                #endregion
                
                #region Methods
                
                private void OnLookUpQueryChanged(object sender, EventArgs e)
                {
                        this.CustomersSource.GetData
                        (
                                this.LookUpDescriptor,
                                (customers) =>
                                {
                                        if (this.LookUpDescriptor.PageDescriptor.PageIndex > 0)
                                        {
                                                ObservableCollection<object> items = this.Customers as ObservableCollection<object>;
                                                foreach (var customer in customers)
                                                {
                                                        items.Add(customer);
                                                }
                                        }
                                        else
                                        {
                                                ObservableCollection<object> items = new ObservableCollection<object>(customers.Cast<object>());
                                                this.Customers = items;
                                        }
                                },
                                (totalItemCount) =>
                                {
                                        if (totalItemCount != -1)
                                                this.LookUpDescriptor.PageDescriptor.TotalItemCount = totalItemCount;
                                },
                                (error) =>
                                {
                                        this.Presenter.ShowErrorMessage(
                                                "An exception has occurred during data loading\n." +
                                                "Message: " + error.Message +
                                                "Stack Trace: " + error.StackTrace);
                                }
                        );
                }
                
                #endregion
        }
} 
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

UXDataComboBox Class
UXDataComboBox Members

Send Feedback