This is a migrated thread and some comments may be shown as answers.

SelectedItem not casting to binding type

3 Answers 101 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
dsoltesz
Top achievements
Rank 1
dsoltesz asked on 22 Dec 2008, 04:30 PM

If I try to cast the Selected item to the binding type its always null.  I'm using hierarchicial databinding.  If i try to cast object to level 1 or level 2 in the hierarchary, cast always fails or is null.

 

 

 

 

if (m_CatQuestionBar.HasSelectedItem())
{
    Category selectedCategory = m_CatQuestionBar.SelectedItem as Category
    if(selectedCategory != null)
    {
        //do something
    }
    else
    {
        //unable to cast
    }
}

I can provide a sample app if needed

 

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav
Telerik team
answered on 23 Dec 2008, 03:23 PM
Hello Dan,

I confirmed the incorrect behavior: It seems that the Panelbar returns the container wrapper and not the data item. Currently, to get the data item you need to retrieve it from the DataContext of the item, for example:

(panelBar.SelectedItem as Control).DataContext 

This will be fixed in the next ServicePack release of the controls.

Thank you for your feedback! Your Telerik Points have been updated.

Greetings,
Miroslav
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Matthew Cartwright
Top achievements
Rank 1
answered on 25 Mar 2009, 04:18 PM
Hi,

Which version of the control was this broken in, and which version will it be fixed in?

Thanks,
0
Tihomir Petkov
Telerik team
answered on 26 Mar 2009, 11:55 AM
Hi Matthew,

This bug was fixed for our 2009 Q1 release.

Regards,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
PanelBar
Asked by
dsoltesz
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Matthew Cartwright
Top achievements
Rank 1
Tihomir Petkov
Telerik team
Share this question
or