I have this databound tileview declared (part of an itemscontrol):
In the code behind I have:
So, when the tileview is loaded I set it's ItemsSource and subscribe to the ItemContainerGenerator.StatusChanged event. If I add an item to the ItemsSource the event fires and I need to find which tileview raised it (ParentTileView of ContainerFromIndex(0)). I do get a reference to the TileViewItem, but it's ParentTileView property is nothing. If I add a second item the ParentTileView is suddenly pointing to the correct tileview. Is this intentional? Is there another way to find which tileview raised the event?
<
telerik:RadTileView
ItemContainerStyle
=
"{StaticResource RadTileViewItemStyle1}"
IsSelectionEnabled
=
"True"
SelectionMode
=
"Single"
MaxRows
=
"1"
IsAnimationOptimized
=
"True"
Loaded
=
"TileView1_Loaded"
PreviewTileSelectionChanged
=
"TileView1_PreviewTileSelectionChanged"
MaximizeMode
=
"Zero"
/>
In the code behind I have:
Private
Sub
TileView1_Loaded(sender
As
System.
Object
, e
As
System.Windows.RoutedEventArgs)
Dim
_tv
As
RadTileView = sender
_tv.ItemsSource =
DirectCast
(_tv.DataContext, main_data_tab).details_tab
AddHandler
_tv.ItemContainerGenerator.StatusChanged,
AddressOf
ItemContainerGenerator_StatusChanged
End
Sub
Private
Sub
ItemContainerGenerator_StatusChanged(sender
As
Object
, e
As
System.EventArgs)
Dim
_cg = TryCast(sender, Telerik.Windows.Controls.ItemContainerGenerator)
If
_cg IsNot
Nothing
And
_cg.Status = Primitives.GeneratorStatus.ContainersGenerated
Then
Dim
_tileview =
DirectCast
(_cg.ContainerFromIndex(0), RadTileViewItem).ParentTileView
If
_tv IsNot
Nothing
Then
For
Each
_item
In
_tv.Items
Dim
_container
As
RadTileViewItem = _cg.ContainerFromItem(_item)
If
_container.Tag
Is
Nothing
Then
AddHandler
_container.MouseEnter,
AddressOf
RadTileViewItem_MouseEnter
_container.Tag =
"Processed"
End
If
Next
End
If
End
If
End
Sub
So, when the tileview is loaded I set it's ItemsSource and subscribe to the ItemContainerGenerator.StatusChanged event. If I add an item to the ItemsSource the event fires and I need to find which tileview raised it (ParentTileView of ContainerFromIndex(0)). I do get a reference to the TileViewItem, but it's ParentTileView property is nothing. If I add a second item the ParentTileView is suddenly pointing to the correct tileview. Is this intentional? Is there another way to find which tileview raised the event?