I am using the RADDomainDataSource to expose my data model via a ViewModel to my View.
Here is a sample of my code i have build with the help from this forum and samples provided by telerik.
It works very well. I bind the data to a Grid as Well as a DataForm.
Inside my Organistions class i have a collections of Offices like this:
Organisations.Offices.
I can bind to a new Grid like so:
Which also works. However i wanted to bind a dataform to one specific Office.
Previously when i did not use MVV and none of the telerik controls, i did something like that by creating a filter like this:
And using it in the XAML.
I see that the DomainDatSource has filters, is that something i could use in this case, and how would i do that, considering my DomainDataSource is in my ViewModel.
Thanks
Here is a sample of my code i have build with the help from this forum and samples provided by telerik.
RabbitDomainContext _context =
new
RabbitDomainContext();
public
ICommand SaveChangesCommand {
get
;
set
; }
public
ClientsViewModel()
{
if
(!DesignerProperties.IsInDesignTool)
{
EntityQuery<Organisation> getOrganisationQuery = _context.GetOrganisationsQuery();
_organisations =
new
QueryableDomainServiceCollectionView<Organisation>(_context, getOrganisationQuery);
_organisations.PageSize = 25;
_organisations.AutoLoad =
true
;
SaveChangesCommand =
new
DelegateCommand(SaveChanges, CanSaveChanges);
}
}
private
QueryableDomainServiceCollectionView<Organisation> _organisations;
public
IEnumerable Organisations
{
get
{
return
_organisations; }
}
private
Organisation _selectedOrganisation;
public
Organisation SelectedOrganisation
{
get
{
return
_selectedOrganisation; }
set
{
if
(value != _selectedOrganisation)
{
_selectedOrganisation = value;
OnPropertyChanged(
"SelectedOrganisation"
);
}
}
}
private
bool
CanSaveChanges(
object
param)
{
return
true
;
}
private
void
SaveChanges(
object
param)
{
_organisations.SubmitChanges();
}
It works very well. I bind the data to a Grid as Well as a DataForm.
Inside my Organistions class i have a collections of Offices like this:
Organisations.Offices.
I can bind to a new Grid like so:
ItemsSource=
"{Binding SelectedOrganisation.Offices}"
Which also works. However i wanted to bind a dataform to one specific Office.
Previously when i did not use MVV and none of the telerik controls, i did something like that by creating a filter like this:
And using it in the XAML.
private
void
PhoneViewSource_Filter(
object
sender, System.Windows.Data.FilterEventArgs e)
{
if
(((CommsMethod)e.Item).Z_Position == 0 && ((CommsMethod)e.Item).Owner_Type == 0)
e.Accepted =
true
;
else
e.Accepted =
false
;
}
I see that the DomainDatSource has filters, is that something i could use in this case, and how would i do that, considering my DomainDataSource is in my ViewModel.
Thanks