<scheduleView:RadScheduleView AppointmentsSource="{Binding Appointments}" Margin="10" ResourceTypesSource="{Binding ResourceTypes}" telerik:StyleManager.Theme="Windows7" TimeMarkersSource="{Binding TimeMarkers}" CategoriesSource="{Binding Categories}" x:Name="MyScheduleView" GroupHeaderContentTemplateSelector="{StaticResource GroupHeaderContentTemplateSelector}" FirstDayOfWeek="Monday" FirstVisibleTime="6:0:0" ActiveViewDefinitionIndex="1" DialogClosing="MyScheduleView_DialogClosing" SpecialSlotsSource="{Binding SpecialSlots}" SpecialSlotStyleSelector="{StaticResource SpecialSlotStyleSelector}" ToolTipTemplate="{StaticResource AppointmentToolTipTemplate}" Drop="MyScheduleView_Drop">
static MainWindow(){ RadRibbonWindow.IsWindowsThemeEnabled = false;}Hi,
we would like to switch our DataGrid loading mechanism to use the QueryableDataServiceCollectionView (on top of DataServiceContext), to mainly take advantage of paging, maybe filtering.
However due to some rich functionality in the grid, we are wrapping each 'RowModel' (record) with a 'RowViewModel', supporting the functionality in the grid. So the collection we currently bind the DataGrid.ItemsSource is of type IEnumerable<RowViewModel> rather than IEnumerable<RowModel>. This is done simply by running something like PageViewModel.GridItemsSource = data.Select(m => new RowViewModel(m));
The question is how to achieve the same result with QueryableDataServiceCollectionView? The records loaded will obviously be of type RowModel, however we would like to 'convert' them to 'RowViewModel' instances and bind those to the grid.
Any ideas?
Stevo
class Company : IDataErrorInfo { public int _id; public int id { get { return _id; } set { _id = value; } } public string _name; public string name { get { return _name; } set { _name= value; } } public string Error { get; set; } public string this[string columnName] {// . . . } public static void Add(Company ist) {// . . . } public static void Edit(Company ist) {// . . . } public static void Delete(Company ist) {// . . . } public static List<Company> Get() {// . . . }
} class Product: IDataErrorInfo { public int _id; public int id { get { return _id; } set { _id = value; } } public string _name; public string name { get { return _name; } set { _name= value; } } public Company _comp; public Company comp { get { return _comp; } set { _comp= value; } } public string Error { get; set; } public string this[string columnName] {// . . . } public static void Add(Product ist) {// . . . } public static void Edit(Product ist) {// . . . } public static void Delete(Product ist) {// . . . } public static List<Product> Get() {// . . . }}private void DataForm1_AutoGeneratingField_1(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e){ if (e.PropertyName == "Error" || e.PropertyName == "id") { e.Cancel = true; } else if (e.PropertyName == "comp") { e.DataField = new DataFormComboBoxField() { ItemsSource = viewModel.companies, DisplayMemberPath = "name", SelectedValuePath = "id", DataMemberBinding = new Binding("comp.id") { Mode = BindingMode.TwoWay }, Label = "Company" }; } e.DataField.DataMemberBinding.ValidatesOnDataErrors = true; e.DataField.DataMemberBinding.NotifyOnValidationError = true;}