Derived RadTileViewItem Not Displaying Correctly

4 posts, 0 answers
  1. Tyrin-J
    Tyrin-J avatar
    9 posts
    Member since:
    Apr 2008

    Posted 08 Dec 2009 Link to this post

    The RadTileView control is an amazing control with great potential. However, I am unable to get the best out of it; your documentation is scanty.

    Our solution requires us using the RadTileViewItem as a container for other controls (with fairly extensive design). This container (RadTileViewItem ) will be instantiated by users when they click a menu item. We thought making this a custom control inheriting from RadTileViewItem would solve the problem. 

    Upon instantiating our newly derived control, we noticed that our derived control was hosted in another RadTileView; so it seems. Every time you create a new instance of the derived control, it is hosted inside another RadTileView. Is there anything we are not doing.

    Also, we noticed that we cant edit the TextBlock inside the derived control; it behaves as if it is now readonly.

    Please, your quick response will be highly appreciated so that we can finish our POC for a client.

    Oriaz
  2. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 13 Dec 2009 Link to this post

    Hello Tyrin-J,

    The RadTileView control and ItemsControls in general, have an IsItemItsOwnContainerOverride() method which is used for determining whetner an object in the Items collection of the control is a suitable container. If for example you put a list of string objects in a ListBox, each string will be wrapped in a dynamically created ListBoxItem container. The same goes for all ItemsControls, including the TileView and this is the reason why your derived controls are wrapped in TileViewItem containers. If you want to avoid this, you must inherit the TileView control and override its IsItemItsOwnContainerOverride() method. Below is a short example:

    public class MyTileView : RadTileView
    {
    protected override bool IsItemItsOwnContainerOverride(object item)
    {
    return item is MyTileViewItem;
    }
    }

    public class MyTileViewItem : RadTileViewItem
    {

    }

    Let me know if this helps.

    Kind regards,
    Tihomir Petkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Tyrin-J
    Tyrin-J avatar
    9 posts
    Member since:
    Apr 2008

    Posted 13 Dec 2009 Link to this post

    Hi,

    I am still getting the same result. Is there something I am missing?

    ' Derived tile view

    Partial

     

    Public Class TileView

     

     

    Inherits Telerik.Windows.Controls.RadTileView

     

     

    Public Sub New()

     

     

        MyBase.New()

     

            InitializeComponent()

     

        End Sub

     

     

     

     

        Protected

     

    Overloads Overrides Function IsItemItsOwnContainerOverride(ByVal item As Object) As Boolean

     

     

            Return (TypeOf item Is overa.instantmessaging.ChatView)

     

     

        End Function

     

     

     

    End

     

    Class

     



    ' Derived TileViewItem

    Partial

     

    Public Class ChatView

     

     

    Inherits Telerik.Windows.Controls.RadTileViewItem

     

     

        Public Sub New()

     

            InitializeComponent()

     

        End Sub

     

    End

     

    Class

     


    I also noticed that when the application is loaded, a radtileviewitem is created by default. This is not desirable.

    My original question was 2-part. The textblocks in the derived radtileviewitem are locked preventing data input. How can this behaviour be removed.
  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 16 Dec 2009 Link to this post

    Hello Tyrin-J,

    I have created a sample project that contains an inherited tile view item. The inherited tile view item (MyTileViewItem) gets its style from the themes\generic.xaml. For the sake of the example, I have added a TextBox in the ControlTemplate of MyTileViewItem. Have a look at the sample project and if you find something unclear, let me know.


    Best wishes,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top