Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I need to pass object from xaml(view ) to view model using binding


eg

XML
<Grid x:Name="LayoutRoot" Background="White">
<telerik:RadGridView Height="400" Width="400" AutoGenerateColumns="True" x:Name="radObject" />
    </Grid>


I need to pass this RadGridInstance to viewmodel using binding any idea

Thanks in Advance
Posted

1 solution

Why you would want to pass the GridView seems a bit odd, is it possible that you are looking for:
http://www.telerik.com/help/silverlight/telerik.windows.data-telerik.windows.controls.datacontrol-selecteditem.html[^]
or
http://www.telerik.com/help/silverlight/telerik.windows.data-telerik.windows.controls.datacontrol-currentitem.html[^]
or
http://www.telerik.com/help/silverlight/telerik.windows.data-telerik.windows.controls.datacontrol-selecteditems.html[^]

Those properties are usually what you would like to provide bindings for in a view model - apart from
http://www.telerik.com/help/silverlight/telerik.windows.data-telerik.windows.controls.datacontrol-items.html[^]
or
http://www.telerik.com/help/silverlight/telerik.windows.data-telerik.windows.controls.datacontrol-itemssource.html[^] - one of them is usually the simplest way to bind the actual data, while those above allows you to react to user input in a sensible manner.

Regards
Espen Harlinn
 
Share this answer
 
Comments
Gopinath Sugumar 25-Mar-11 6:38am    
Hi thanks ,
but me need to call some methods like
radObject.ScrollIntoView(radObject.SelectedItem);
in viewmodel ,i dont want to write code on codebehin file
Espen Harlinn 27-Mar-11 10:38am    
If I remember correctly - binding to currentitem allows you to solve this :) - I havent used the telerik grid control for SilverLight since other alternatives became available ...
Gopinath Sugumar 28-Mar-11 1:56am    
Thanks,
But binding to currentitem will give us the single current item object(ex employee object from employee list) not Gridview Instance
Espen Harlinn 28-Mar-11 6:50am    
I'm trying to help you find, INMO, a "better" solution. CurrentItem will become visible through binding when set in the View Model - assuming that you have implemented change notification on the property you bind to. The general idea is that the View Model does not know anything about the actual control used to implment the UI - it implments a data model for the UI functionality, not a full datamodel for the solution. The view model also contains data members that drives the UI - like a collection for SelectedItems and a property for CurrentItem.
Gopinath Sugumar 29-Mar-11 0:09am    
yes Espen ur right ,but if i need to call a method which belongs to control like
radObject.ScrollIntoView(radObject.SelectedItem);
What i need to do,I can use code behind but when the selected item is get changed i need to call
this ,so it means i need to place this in selecteditem changed event in the code behind is it right ?
But without using code behind is any way .....(ie handling methods of object in view model)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900