MEF Imported User Controls, Binding TileViewItem Header To Property In User Control

2 posts, 0 answers
  1. Martyn
    Martyn avatar
    18 posts
    Member since:
    Mar 2011

    Posted 16 Sep 2011 Link to this post


    I am importing several user controls with MEF into an ObservableCollection<UserControl> in my view model.

    I am then binding the ItemsSource of my RadTileView to this ObservableCollection.

    I want to set the Header of the tile view item to be bound to a string Property in the imported Views named "Title". I have set the property to NotifyPropertyChanged() when it is set and I have the following DataTemplate for the Tile Header:

            <DataTemplate x:Key="ModuleTileHeaderTemplate">
                <TextBlock Text="{Binding Title}"/>

    I have then applied this to the RadTileView like this:

    <telerik:RadTileView Name="radTileView1" ItemsSource="{Binding HomeViews}" ItemTemplate="{StaticResource ModuleTileHeaderTemplate}" MinimizedItemsPosition="Top" MaximizeMode="ZeroOrOne">
                    <Style TargetType="telerik:RadTileViewItem">
                        <Setter Property="MinimizedWidth" Value="100"/>

    However, the header of the TileViewItems is still empty.

    What am I doing wrong?

    Thanks for your help.

  2. Zarko
    Zarko avatar
    755 posts

    Posted 20 Sep 2011 Link to this post

    Hello Martyn,
    You're experiencing this problem because you're binding the RadTileView to a collection of UIElements(UserControl). When a RadTileViewItem is generated from a binding it checks if the item that comes from this binding is an UIElement and if it's not it sets it as Content and Header, but if the item is an UIElement it is set only as a Content (because an UIElement can not be set in two places in the VisualTree). That's why in the header template you don't have access to the Title property of you UserControl. You can work around this by binding the Title property to the Header property of the RadTileViewItem with a ContainerBinding.
    For further information please examine the attached project and if you have more questions feel free to ask.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top