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

TileType not applied when Tiles are dynamically created

1 Answer 111 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Nereo asked on 24 Jul 2014, 01:14 PM


The scenario is as follows:

The ViewModel exposes an ObservableCollection of ViewModels
The View has a RadTileList with AutoGenerateTiles=true and Wiring up the AutoGeneratingTile event to set the background color of the Tiles
The Tiles are created dynamically by using DataTemplates based on the type of the ViewModel of the collection of ViewModels exposed by the View's ViewModel
The TileType is bound as every VM in the exposed collection has this property as well.

<tiles:TscTileList x:Name="HomeTileList"
                             ItemsSource="{Binding TileListContentControls, Mode=OneWay}"
                             SelectedItem="{Binding SelectedTileListContentControl, Mode=TwoWay}"
                <DataTemplate DataType="{x:Type home:TileListTileContentControlViewModel}">
                    <tiles:TscTile Title="{Binding NavigationItem.Name}" Image="{Binding NavigationItem.Image}" TileType="{Binding TileType}" Style="{StaticResource SimpleTileStyle}"/>
                <DataTemplate DataType="{x:Type home:AboutTargetWidgetTileListContentControlViewModel}">
                    <tiles:TscTile Title="{Binding NavigationItem.Name}" Image="{Binding NavigationItem.Image}" TileType="{Binding TileType}" Style="{StaticResource AboutTheTargetWidgetStyle}"/>
                <i:EventTrigger EventName="SelectionChanged">
                    <command:EventToCommand Command="{Binding TileSelectedCommand}"
                                            CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}"/>

According to my understanding, as the TileType is bound and is not being set anywhere else (niether in the AutoGeneratingTile event nor in the styles) each of the dynamically created Tiles should stick to the programatically (via XAML) assigned value.

I extended (with empty content, just to understand) the RadTileList and the Tile to be able to see the order of the execution and it happens as follows in the Dynamic scenario:
- Extended RadTileList's AutoGeneratingTile event happens first. It does not matter what is specified in XAML the e.Tile.TileType is always double (I guess because it is the default value of the enum)
-View's AutoGeneratingTile follows with the same behavior

The two above happen in an alternat manner: one then the other until all tiles are "rendered".
- Then, the Extended Tile constructor is fired (for all of them) and the this.Base.TileType property is correctly set here, but as, it was already painted with the value (enum default) found in the AutogeneratingTile events... there is no way to get rid of it and get it work properly unelss using reflection in the AutoGeneratingTile event and manually assingning it.

Is there anyway to make RadTileList repect the value of the TileType in the DataTemplate when doing it dynamically? (it happens the same when the value is explicited in the DataTemplate instead of binding it).

Thanks in advance

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 29 Jul 2014, 10:06 AM
Hello Nereo,

Thank you for reporting the issue,

We will research the cause of the problem and will try to resolve it as soon as possible. 

Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question