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

Possible bug in tileview: adding tileitems after loaded

5 Answers 62 Views
TileView
This is a migrated thread and some comments may be shown as answers.
toto rto
Top achievements
Rank 1
toto rto asked on 10 Aug 2010, 08:58 PM
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

5 Answers, 1 is accepted

Sort by
0
Miro Miroslavov
Telerik team
answered on 13 Aug 2010, 11:41 AM
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
0
toto rto
Top achievements
Rank 1
answered on 16 Aug 2010, 03:58 PM
hello, i can not attach zip files. how can i send the reproduced bug?

thanks
0
Miro Miroslavov
Telerik team
answered on 16 Aug 2010, 04:00 PM
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
0
toto rto
Top achievements
Rank 1
answered on 16 Aug 2010, 04:04 PM
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

0
Accepted
Miro Miroslavov
Telerik team
answered on 17 Aug 2010, 07:14 AM
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
Tags
TileView
Asked by
toto rto
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
toto rto
Top achievements
Rank 1
Share this question
or