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
;
}
<
Style
x:Key
=
"rowStyle"
BasedOn
=
"{StaticResource {x:Type telerik:TreeListViewRow}}"
TargetType
=
"{x:Type telerik:TreeListViewRow}"
>
<
Style.Setters
>
<
EventSetter
Event
=
"MouseDoubleClick"
Handler
=
"HandleRowDoubleClick"
/>
</
Style.Setters
>
</
Style
>
<
Style
x:Key
=
"alternateRowStyle"
BasedOn
=
"{StaticResource rowStyle}"
TargetType
=
"{x:Type telerik:TreeListViewRow}"
>
</
Style
>
<
Style
x:Key
=
"alternateRowStyle"
BasedOn
=
"{StaticResource rowStyle}"
TargetType
=
"{x:Type telerik:TreeListViewRow}"
>
<
Style.Setters
>
<
Setter
Property
=
"Background"
Value
=
"{Binding AlternateRowBackground, Source={RelativeSource TemplatedParent}}"
/>
</
Style.Setters
>
</
Style
>
I just installed the latest version of WPF controls (2013.3.1016.40) and my TreeView no longer registers this property. Can you tell me what the new alternative is for this property? Thanks.
tv.ItemsOptionListType = OptionListType.CheckList;