This question is locked. New answers and comments are not allowed.
Hi !!!
In my SelectionChanging Event isn´t the selecteditem supposed to be the current item and not the selected one ?
If I watch my sender property then the selecteditem is always the newly selected one and not the current item.
Trying to implement some logic before changing to the new selecteditem.
Regards
Fredrik
P.s Running version 2011.1.420.1037 of Controls.Input D.s
In my SelectionChanging Event isn´t the selecteditem supposed to be the current item and not the selected one ?
If I watch my sender property then the selecteditem is always the newly selected one and not the current item.
Trying to implement some logic before changing to the new selecteditem.
Regards
Fredrik
P.s Running version 2011.1.420.1037 of Controls.Input D.s
4 Answers, 1 is accepted
0
Hello Fredrik,
Due to the specifics of the Silverlight's dependency properties, there is are two cases when the SelectedItem will point to the newly selected item when the SelectionChanging event is fired. The first case is when the SelectedItem property is set programmatically. The second case is when the SelectedItem is set via binding. If you select an item by tapping on a visual container in the RadDataBoundListBox control, the SelectionChanging event will be fired prior the initialization of the SelectedItem property.
This is implied because we cannot hook and validate the input when setting the SelectedItem property via binding or programmatically and thus prevent it from being initialized with a value that might be canceled upon the SelectionChanging event.
I hope this explains the case.
Do not hesitate to get back to us in case you have further questions or need assistance.
All the best,
Deyan
the Telerik team
Due to the specifics of the Silverlight's dependency properties, there is are two cases when the SelectedItem will point to the newly selected item when the SelectionChanging event is fired. The first case is when the SelectedItem property is set programmatically. The second case is when the SelectedItem is set via binding. If you select an item by tapping on a visual container in the RadDataBoundListBox control, the SelectionChanging event will be fired prior the initialization of the SelectedItem property.
This is implied because we cannot hook and validate the input when setting the SelectedItem property via binding or programmatically and thus prevent it from being initialized with a value that might be canceled upon the SelectionChanging event.
I hope this explains the case.
Do not hesitate to get back to us in case you have further questions or need assistance.
All the best,
Deyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Fredrik
Top achievements
Rank 1
answered on 14 Jun 2011, 09:38 AM
Hi Deyan !!!
Thanks for your answer....
I´m trying to implement a custom TemplateSelector.
What I need is a way to set back my current selected row to my normaltemplate from my "selected template" when tapping on a new row.
If I cant use the SelectionChanging event how can I do this?
I'm using the ItemTap event for setting my "selected template" for a row.
Regards
Fredrik
Thanks for your answer....
I´m trying to implement a custom TemplateSelector.
What I need is a way to set back my current selected row to my normaltemplate from my "selected template" when tapping on a new row.
If I cant use the SelectionChanging event how can I do this?
I'm using the ItemTap event for setting my "selected template" for a row.
Regards
Fredrik
0
Accepted
Hi Fredrik,
Thanks for writing back.
You still could use the SelectionChanging event and access the previous selected item from the event arguments. Take a look at the code snippet below:
I hope this helps.
Do not hesitate to get back to us in case you have further questions or need assistance.
Kind regards,
Deyan
the Telerik team
Thanks for writing back.
You still could use the SelectionChanging event and access the previous selected item from the event arguments. Take a look at the code snippet below:
void
listBox_SelectionChanging(
object
sender, SelectionChangingEventArgs e)
{
if
(e.RemovedItems.Count > 0)
{
object
oldItem = e.RemovedItems[0];
RadDataBoundListBoxItem visualContainer =
this
.listBox.GetContainerForItem(oldItem)
as
RadDataBoundListBoxItem;
if
(visualContainer !=
null
)
{
//TODO: set normal template of old selected item
}
}
}
I hope this helps.
Do not hesitate to get back to us in case you have further questions or need assistance.
Kind regards,
Deyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Fredrik
Top achievements
Rank 1
answered on 14 Jun 2011, 02:52 PM
Hi !!!
That solved the problem.
Excellent support on telerik....credits to you guys.
Regards
Fredrik
That solved the problem.
Excellent support on telerik....credits to you guys.
Regards
Fredrik