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

Header not Displaying after Remove/Add

3 Answers 73 Views
TileView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mike
Top achievements
Rank 1
Mike asked on 27 Mar 2012, 09:25 PM
We are using version 2011.2.712.1040 of the Telerik Silverlight 4 controls.  When we remove a tile view item from a Tile View and then add that tile view item back to the tile view the Header no longer displays.  It shows the header text is there in debug mode but it doesnt display when the tile view item is rendered.

The following sample app reproduces the problem:

<UserControl x:Class="SilverlightApplication1.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
 
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
         
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <Button Content="Add" Name="Button1" />
            <Button Content="Remove" Name="Button2" />
        </StackPanel>
 
        <telerik:RadTileView x:Name="TileViewHost" MaximizeMode="ZeroOrOne" MinimizedColumnWidth="200"  MaxColumns="2" ScrollBarVisibility="Auto" Grid.Row="1"  />
    </Grid>
</UserControl>
Partial Public Class MainPage
    Inherits UserControl
    Private WithEvents _HomeDocPanel As RadTileViewItem
    Private panels As New ObservableCollection(Of RadTileViewItem)
    Public Sub New()
        InitializeComponent()
        TileViewHost.ItemsSource = panels
    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        If _HomeDocPanel Is Nothing Then
            _HomeDocPanel = New RadTileViewItem
        End If
        _HomeDocPanel.Header = "New Header"
        panels.Add(_HomeDocPanel)
    End Sub
 
    Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
        panels.Remove(_HomeDocPanel)
    End Sub
End Class

Please let us know if there is a fix for this.

Thanks, Mike

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 30 Mar 2012, 12:42 PM
Hi Mike,

Usually, it is bad practice to bind the RadTileView to collection of RadTileViewItems. The RadTileViewItems are actually the containers for the data you wish to present. When using the ItemsSource, you have to provide collection of objects/ViewModels/Entities and define ItemTemplate/ContentTemplate. These templates define the way the auto-generated RadTileViewItems will be presented (their Header/Content).
Please check out your code re-factored in the attached solution and let us know if you need further assistance.

Greetings,
Petar Mladenov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Mike
Top achievements
Rank 1
answered on 02 Apr 2012, 07:12 PM
We are loading different user controls and content into each TileViewItem so this doesn't really work for us.  It would be nice if it would just display the header when we remove and add the item.
0
Petar Mladenov
Telerik team
answered on 05 Apr 2012, 07:48 AM
Hello Mike,

 If you need to add/remove RadTileViewItems dynamically, you should only use the Items collection of the RadTileView. Passing a UIControls in an ItemsSource collection usually leads to various issues and it is considered as a bad practice.
Furthermore, RadTileView provides ItemTemplateSelector and ContentTemplateSelector - in databinding scenarios , they will apply different HeaderTemplates / ContentTemplate to the RadTileViewItems according to the type of the business object. So you can load GridViews if the business object is of type GridViewModel. or Chart if the business object is ChartViewModel, etc.

All the best,
Petar Mladenov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TileView
Asked by
Mike
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Mike
Top achievements
Rank 1
Share this question
or