Possible bug in tileview: adding tileitems after loaded

6 posts, 1 answers
  1. toto rto
    toto rto avatar
    17 posts
    Member since:
    Aug 2012

    Posted 10 Aug 2010 Link to this post

    Hello,

    i might have found a possible bug with the tileview, and i would like to check here.

    i have some tileitems which load programmatically a style, content template, etc in their constructor.

    if i add a tileview in the xaml with the tileitems in the xaml too, items load correctly and their style / templates are properly applied with all contents of the item defined in the templates accessible in the visual tree.

    if i leave the tileview in the xaml, but i add tile items programmatically later after loaded event, the items DO NOT get their styles applied (at least, nothing is visible in the visual tree).

    if i remove the tile item form the xaml and load it programmatically with the tile items (after the on load of the main page), everything works fine.

    it seems that the tileview initializes its tile items (and their styles/templates) on its loaded event but then doesnt initialize any other item added programmatically after it is loaded. This is very annoying for dynamic add/remove of tile items in a loaded tileview.

    any thoughts? if it is a bug, can we fix this in the next service pack?

    thanks
  2. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 13 Aug 2010 Link to this post

    Hello toto rto,

    I've just tested your scenario and couldn't reproduce it. Can you please find the attached project and check if everything is OK? If you can modify showing the problem, it will be of great help to us.
    Thank you.

    Regards,
    Miro Miroslavov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. toto rto
    toto rto avatar
    17 posts
    Member since:
    Aug 2012

    Posted 16 Aug 2010 Link to this post

    hello, i can not attach zip files. how can i send the reproduced bug?

    thanks
  5. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 16 Aug 2010 Link to this post

    Hi toto rto,

    You can create new support ticket for that issue and attache the archive there.

    All the best,
    Miro Miroslavov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. toto rto
    toto rto avatar
    17 posts
    Member since:
    Aug 2012

    Posted 16 Aug 2010 Link to this post

    ok, Ticket has been created with number 339029

    here is the text of the ticket:

    so, here it is, you will notice that i created classes that inherit RadTileViewItem. The item have a custom template which has a button on the main header bar.  on its own loaded event, the tileview item searches the visualtree for the button and attaches the click event.

    now, this works fine for items that are added before the tileview gets its loaded event. every item added after this will have the visual tree search for the buttton return null, which makes it impossible to find the button (or oother header controls) and attach to its events, edit properties.

    this bug is very serious for those who wish to addremove tile items dynamically once the app has loaded.

    hope this helps,

    thanks

  7. Answer
    Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 17 Aug 2010 Link to this post

    Hello toto rto,

    In Silverlight - Applying the control's template is not ensured to be present before the Loaded event of the Control. Which means that is possible in some cases to have Loaded event before the actual ApplyTemplate has passed (this is true for all controls, not only for telerik ones). But before the applying of template has passed, you can not depend on the visual tree (it is not build yet).
    To ensure that the template is applied, you can call the this.ApplyTemplate() just before the code that depend on the template.

    void CustomTile_Loaded(object sender, RoutedEventArgs e)
           {
               this.ApplyTemplate();
     
               DependencyObject button = FindVisualChildByName(this, "CustomButton");
     
               //var button = this.FindChildByType<Button>();
     
               if (button != null)
               {
                   ((Button)button).Click += new RoutedEventHandler(CustomTile_Click);
               }
               else
                   MessageBox.Show(string.Format("Item {0} has a bug. lookup of textbox by Visual Tree failed, bug in the adding of RadTileViewItem after tileview is loaded!", this.Header));
           }

    Hope everything will be correct this way.

    Kind regards,
    Miro Miroslavov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner