This question is locked. New answers and comments are not allowed.
I have a RadGridView in my silverlight application. It looks like this
Source is an IEnumerable on the ViewModel. Everything gets bound properly, when I select an item in the list, the property SelectedItem in the ViewModel gets called.
Sometimes when the page loads, I would like to have a particular row selected.To achieve this I call the setter on SelectedItem programatically, I expect to see the row selected on the UI, but it doesnt seem to happen. (The item that am selecting is one amongst the items in the Source)
Any ideas why?
Thanks
K
<
telerikGrid:RadGridView
ItemsSource
=
"{Binding Source}"
SelectedItem
=
"{Binding SelectedItem, Mode=TwoWay}"
>
Source is an IEnumerable on the ViewModel. Everything gets bound properly, when I select an item in the list, the property SelectedItem in the ViewModel gets called.
Sometimes when the page loads, I would like to have a particular row selected.To achieve this I call the setter on SelectedItem programatically, I expect to see the row selected on the UI, but it doesnt seem to happen. (The item that am selecting is one amongst the items in the Source)
Any ideas why?
Thanks
K
11 Answers, 1 is accepted
0
Hi,
Vlad
the Telerik team
Please make sure that you've raised PropertyChanged of your model.
Greetings,Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Karthik
Top achievements
Rank 1
answered on 01 Mar 2012, 01:10 PM
Vlad
I do have the propertychanged event raised on my model. Any other ideas?
Thanks
K
I do have the propertychanged event raised on my model. Any other ideas?
Thanks
K
0
Hi,
Vlad
the Telerik team
Can you post more info about your version?
Regards,Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Karthik
Top achievements
Rank 1
answered on 01 Mar 2012, 01:16 PM
Vlad,
Am using SIlverlight 4 with Telerik Controls from version 2011.2.712.1040.
Thanks
K
Am using SIlverlight 4 with Telerik Controls from version 2011.2.712.1040.
Thanks
K
0
Hi Karthik,
Can you give us more details about your implementation - how do you assign the SelectedItem? Which event you are using for doing this? Do you set the property of the view model or the SelectedItem property of RadGridView?
Greetings,
Yordanka
the Telerik team
Can you give us more details about your implementation - how do you assign the SelectedItem? Which event you are using for doing this? Do you set the property of the view model or the SelectedItem property of RadGridView?
Greetings,
Yordanka
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Karthik
Top achievements
Rank 1
answered on 01 Mar 2012, 04:46 PM
Yordanka ,
The SelectedItem is a property on the ViewModel and that property gets assigned a value based on some other event.
It looks as simple as this
The property seems to work, because when I select an item in the grid, the setter property gets called appropriately.
Thanks
K
The SelectedItem is a property on the ViewModel and that property gets assigned a value based on some other event.
It looks as simple as this
public
SomeObject SelectedItem {
get
{
return
_selectedItem}
set
{
if
(value ==
null
)
return
;
_selectedItem = value;
OnPropertyChanged(
"SelectedItem"
)
}
}
The property seems to work, because when I select an item in the grid, the setter property gets called appropriately.
Thanks
K
0
Hi Karthik,
Maya
the Telerik team
Could you verify how do you set the SelectedItem of RadGridView ? Do you set directly SelectedItem property of RadGridView or you set it through the SelectedItem property of your ViewModel ?
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Karthik
Top achievements
Rank 1
answered on 01 Mar 2012, 05:25 PM
Was the reply below not sufficient? If it wasn't can you please elaborate what you are asking me. Please bear with my ignorance, am a newbie to all this.
Thanks
K
Thanks
K
0
Hi Karthik,
Or you count entirely on the binding and set the SelectedItem property from your view model:
All the best,
Maya
the Telerik team
Do you at any place set SelectedItem similar to:
this.myRadGridView.SelectedItem
= this.myRadGridView.Items[1];
Or you count entirely on the binding and set the SelectedItem property from your view model:
myViewModelInstance.SelectedItem = myNewSelectedItem;
All the best,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Karthik
Top achievements
Rank 1
answered on 02 Mar 2012, 02:03 PM
Maya,
I dont do any work in the code behind (neither I do anything like your code snippet one), all my bindings are happening entirely in the view model. (similar to the the second code snippet you have shown)
Thanks
K
I dont do any work in the code behind (neither I do anything like your code snippet one), all my bindings are happening entirely in the view model. (similar to the the second code snippet you have shown)
Thanks
K
0
Doug
Top achievements
Rank 1
answered on 18 Oct 2012, 01:38 AM
So Maya, did you drop the ball on this user or what? I was eager to read this thread, but when I got to the end and it just aborted, I was disappointed, if not worse.
Doug
Doug