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

TileType not applied when Tiles are dynamically created

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

Hi, 

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}"
                             ScrollViewer.HorizontalScrollBarVisibility="Auto"
                             AutoGenerateTile="True"
                             AutoGeneratingTile="HomeTileListAutoGeneratingTile">
             
            <tiles:TscTileList.Resources>
                 
                <DataTemplate DataType="{x:Type home:TileListTileContentControlViewModel}">
                    <tiles:TscTile Title="{Binding NavigationItem.Name}" Image="{Binding NavigationItem.Image}" TileType="{Binding TileType}" Style="{StaticResource SimpleTileStyle}"/>
                </DataTemplate>
                 
                <DataTemplate DataType="{x:Type home:AboutTargetWidgetTileListContentControlViewModel}">
                    <tiles:TscTile Title="{Binding NavigationItem.Name}" Image="{Binding NavigationItem.Image}" TileType="{Binding TileType}" Style="{StaticResource AboutTheTargetWidgetStyle}"/>
                </DataTemplate>
                 
            </tiles:TscTileList.Resources>
             
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <command:EventToCommand Command="{Binding TileSelectedCommand}"
                                            CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </tiles:TscTileList>

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
0
Yoan
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. 


Regards,
Yoan
Telerik
 
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.
 
Tags
TileList
Asked by
Nereo
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or