SelectedItem not casting to binding type

4 posts, 1 answers
  1. dsoltesz
    dsoltesz avatar
    20 posts
    Member since:
    Jan 2008

    Posted 22 Dec 2008 Link to this post

    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

     

     

  2. Answer
    Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 23 Dec 2008 Link to this post

    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.
  3. DevCraft banner
  4. Matthew Cartwright
    Matthew Cartwright avatar
    31 posts
    Member since:
    Oct 2005

    Posted 25 Mar 2009 Link to this post

    Hi,

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

    Thanks,
  5. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 26 Mar 2009 Link to this post

    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.
Back to Top