Header not Displaying after Remove/Add

4 posts, 0 answers
  1. Mike
    Mike avatar
    8 posts
    Member since:
    Feb 2011

    Posted 27 Mar 2012 Link to this post

    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
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 30 Mar 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Mike
    Mike avatar
    8 posts
    Member since:
    Feb 2011

    Posted 02 Apr 2012 Link to this post

    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.
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 05 Apr 2012 Link to this post

    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 >>
Back to Top