In many examples, I see the use of the TileStateChanged event to manually control the tile state. In every example, the first line of code in the event handler is this:
RadTileViewItem item = e.Source as RadTileViewItem;
But when use the same code in my own handler, the e.Source reference is to the RadTileView, not RadTileViewItem. Just to note, I'm wiring the event up in xaml using the following:
Why would the source of the event be different for me than the examples?
RadTileViewItem item = e.Source as RadTileViewItem;
But when use the same code in my own handler, the e.Source reference is to the RadTileView, not RadTileViewItem. Just to note, I'm wiring the event up in xaml using the following:
<my:RadTileView x:Name="ClassOverridesTileView"
ItemsSource="{Binding Classes}"
ItemTemplate="{StaticResource HeaderTemplate}"
ContentTemplate="{StaticResource ContentTemplate}"
TileStateChanged="ClassOverridesTileView_TileStateChanged"
>
</my:RadTileView>
Why would the source of the event be different for me than the examples?
9 Answers, 1 is accepted
0
Hi kilhoffer,
the event source is the TileView, not the TileViewItem. You need to use the e.OriginalSource to get the TileViewItem.
Please let us know if you have more questions.
Greetings,
Valentin.Stoychev
the Telerik team
the event source is the TileView, not the TileViewItem. You need to use the e.OriginalSource to get the TileViewItem.
Please let us know if you have more questions.
Greetings,
Valentin.Stoychev
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

Robin
Top achievements
Rank 1
answered on 13 Jul 2010, 10:43 AM
I just tried both e.source and e.originalsource and both return the object of type RadTileView and NOT RadTileViewItem.
Any ideas, I also need to get a handle on the RadTileViewItem
Thanks
Chris
Any ideas, I also need to get a handle on the RadTileViewItem
Thanks
Chris
0

Robin
Top achievements
Rank 1
answered on 13 Jul 2010, 10:50 AM
Is ok I have discovered what was wrong I was wiring up the wrong event...
TilesStateChanged
and should have wired up
TileStateChanged (with out the s)
:)
chris
TilesStateChanged
and should have wired up
TileStateChanged (with out the s)
:)
chris
0

kilhoffer
Top achievements
Rank 1
answered on 13 Jul 2010, 03:38 PM
So the samples are incorrect? The samples show the Source as being the RadTileViewItem.
0
Hello kilhoffer,
If you define your TileView in XAML and subscribe for TileStateChanged event of RadTileView then the e.Source and e.OriginalSource will be a RadTileViewItem. For example, take this scenario:
However, since you are binding RadTileView, the e.Source will be RadTileView, while the e.OriginalSource will be RadTileViewItem.
Most of the examples on our website do not have binding and in all of them the TileViewItems are defined in XAML. That is why the e.Source is RadTileViewItem.
Greetings,
Kiril Stanoev
the Telerik team
If you define your TileView in XAML and subscribe for TileStateChanged event of RadTileView then the e.Source and e.OriginalSource will be a RadTileViewItem. For example, take this scenario:
<
telerikNavigation:RadTileView
TileStateChanged
=
"RadTileView_TileStateChanged"
>
<
telerikNavigation:RadTileViewItem
Header
=
"Item 0"
/>
<
telerikNavigation:RadTileViewItem
Header
=
"Item 1"
/>
<
telerikNavigation:RadTileViewItem
Header
=
"Item 2"
/>
<
telerikNavigation:RadTileViewItem
Header
=
"Item 3"
/>
</
telerikNavigation:RadTileView
>
private
void
RadTileView_TileStateChanged(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
// here e.Source is RadTileViewItem and e.OriginalSource is RadTileViewItem
}
However, since you are binding RadTileView, the e.Source will be RadTileView, while the e.OriginalSource will be RadTileViewItem.
<
telerikNavigation:RadTileView
x:Name
=
"tileView1"
TileStateChanged
=
"RadTileView_TileStateChanged"
/>
public
MainWindow()
{
InitializeComponent();
this
.tileView1.ItemsSource = Enumerable.Range(0, 4);
}
private
void
RadTileView_TileStateChanged(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
// here e.Source is RadTileView and e.OriginalSource is RadTileViewItem
}
Most of the examples on our website do not have binding and in all of them the TileViewItems are defined in XAML. That is why the e.Source is RadTileViewItem.
Greetings,
Kiril Stanoev
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

Vijay
Top achievements
Rank 1
answered on 19 Jul 2011, 10:17 AM
Hi
I put one usercontrol in tileview datatemplate but I am not able get that usercontrol at time of state change.
Thanks
Vijay
I put one usercontrol in tileview datatemplate but I am not able get that usercontrol at time of state change.
<telerik:RadTileView.ContentTemplate> <DataTemplate> <My:DocumentViewer x:Name="SPDocumentViewer" MinHeight="100" MinWidth="100" FilePath="{Binding FilePath}" paramFromPage="{Binding Sheetno}" paramToPage="{Binding Sheetno}"/> </DataTemplate> </telerik:RadTileView.ContentTemplate>
Thanks
Vijay
0
Hi Vijay,
One way to achieve what you're looking for is to use out ChildrenOfType<T> extension method. Something like this:
However, I'd advice you to use this extension method with caution because it traverses the visual tree of the control (in this case RadTileViewItem) and if the visual tree is large this will impose performance issues. For further reference, please take a look at the attached project.
Regards,
Kiril Stanoev
the Telerik team
One way to achieve what you're looking for is to use out ChildrenOfType<T> extension method. Something like this:
private
void
RadTileView_TileStateChanged(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
RadTileViewItem item = e.OriginalSource
as
RadTileViewItem;
MyUserControl myUserControl = item.ChildrenOfType<MyUserControl>().FirstOrDefault();
if
(myUserControl !=
null
)
{
// MyUserControl found!
}
}
However, I'd advice you to use this extension method with caution because it traverses the visual tree of the control (in this case RadTileViewItem) and if the visual tree is large this will impose performance issues. For further reference, please take a look at the attached project.
Regards,
Kiril Stanoev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
0

Mike
Top achievements
Rank 1
answered on 16 Aug 2011, 09:27 PM
Hi Kiril,
I'm using WPF, TileView with Fluidcontenetcontrl. using the folllowing event handler to change the fluidContols state to change my datatemplate but item.Content as RadFluidContentControl is null! The item is picked up correctly.
what am i doing wrong?
Thanks,
Mike
I'm using WPF, TileView with Fluidcontenetcontrl. using the folllowing event handler to change the fluidContols state to change my datatemplate but item.Content as RadFluidContentControl is null! The item is picked up correctly.
what am i doing wrong?
Thanks,
Mike
private void RadTileView_TileStateChanged(object sender, Telerik.Windows.RadRoutedEventArgs e) { RadTileViewItem item = e.OriginalSource as RadTileViewItem; if (item != null) { RadFluidContentControl fluidControl = item.Content as RadFluidContentControl; if (fluidControl != null) { switch (item.TileState) { case TileViewItemState.Maximized: fluidControl.State = FluidContentControlState.Large; break; case TileViewItemState.Minimized: fluidControl.State = FluidContentControlState.Small; break; case TileViewItemState.Restored: fluidControl.State = FluidContentControlState.Normal; break; } } }
0
Hi Mike,
The item.Content as RadFluidContentControl will work only if your TileView items are RadTileVIewItem (defined in XAML or created added in code behind) i.e. you don't use binding. When you're using business objects for items in your RadTileView you can find the RadFluidContentConrol like this:
For further references could you please examine the attached project and if you have more questions feel free to ask.
All the best,
Zarko
the Telerik team
The item.Content as RadFluidContentControl will work only if your TileView items are RadTileVIewItem (defined in XAML or created added in code behind) i.e. you don't use binding. When you're using business objects for items in your RadTileView you can find the RadFluidContentConrol like this:
RadFluidContentControl fluidControl = item.ChildrenOfType<RadFluidContentControl>().FirstOrDefault();
All the best,
Zarko
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>