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