Maximize RadTileViewItem

7 posts, 0 answers
  1. Titus
    Titus avatar
    11 posts
    Member since:
    Mar 2012

    Posted 11 May 2012 Link to this post

    Hello there,
    I would have a very basic question about how to Maximize a RadTileViewItem from within the item itself. Here is my scenario:
    I'm using a RadTileView to display some dynamic content (text, images, hyperlinks) into a couple of RadTileViewItems.
    I would like to be able to maximize the current RadTileViewItem when the hyperlink is being clicked.
    Thanks in advance for any hint!
  2. Titus
    Titus avatar
    11 posts
    Member since:
    Mar 2012

    Posted 14 May 2012 Link to this post

    Hello there,

    Here is the 2-steps solution that I've found so far. If you guys do have a better solution, please post it here.

    STEP 1: Put a HyperlinkButton inside your <telerik:RadFluidContentControl.Content> </telerik:RadFluidContentControl.Content>as follows:
    <HyperlinkButton
                                                 VerticalAlignment="Bottom"
                                                 Margin="0"
                                                 Padding="0"
                                                 IsTabStop="False"
                                                 BorderBrush="{x:Null}"
                                                 Click="OnClick"
                                                 Style="{StaticResource Hyperlink}"
                                                 Content="Maximize"
                                                 FontFamily="Segoe UI" FontSize="12"                                            
                                                 />

    STEP 2: In your code behind, define the methods OnClick() and FindParentOfType<T>() as follows:
    private void OnClick(object sender, RoutedEventArgs e)
    {
        HyperlinkButton btn = e.OriginalSource as HyperlinkButton;
        RadTileViewItem item = FindParentOfType<RadTileViewItem>(btn);
        item.TileState = TileViewItemState.Maximized;
    }
     
    private static T FindParentOfType<T>(UIElement element) where T : UIElement
    {
        if (element == null) return null;
     
        DependencyObject parent = System.Windows.Media.VisualTreeHelper.GetParent(element);
     
        while ((parent != null) && !(parent is T))
        {
            parent = System.Windows.Media.VisualTreeHelper.GetParent(parent);
        }
     
        return (T)parent;
    }

  3. DevCraft banner
  4. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 16 May 2012 Link to this post

    Hello Titus,
    The solution that you've found is basically the most straightforward one and my only advise is that you could use our ParentOfType method and you won't have to create our own:
    HyperlinkButton btn = e.OriginalSource as HyperlinkButton;
    RadTileViewItem item = btn.ParentOfType<RadTileViewItem>();
    item.TileState = TileViewItemState.Maximized;
    Another way to maximize an item from within its content is to use some of our buttons (because they can have RoutingCommands) like this:
    <telerik:RadButton Width="200"
                    Height="30"
                    Command="tileView:TileViewCommands.ToggleTileState"
                    Content="Toggle TileState" />
    I've attached a sample project showing this so you could examine it and if you have further questions feel free to ask.

    Regards,
    Zarko
    the Telerik team

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

  5. Titus
    Titus avatar
    11 posts
    Member since:
    Mar 2012

    Posted 17 May 2012 Link to this post

    Thanks Zarko, nice trick! Works like a charm!
  6. Henrique
    Henrique avatar
    5 posts
    Member since:
    May 2013

    Posted 15 Oct 2013 Link to this post

    Hi everyone.

    I am trying to add a text and a hyperlink in the content of RadTileViewItem like this...


       HyperlinkButton hyperlink = new HyperlinkButton();
       hyperlink.NavigateUri = new Uri("http://www.uol.com.br", UriKind.Absolute);
       hyperlink.Content = "Uol";
       item.Content = "Test " + hyperlink;
       mainTileView.Items.Add(item);


    But it is not working well. Can anyone help me with this issue?


    BTY I am planning to add two hyperlinks, one for an image and another for a .doc

    Any help will be very welcomed.
  7. Henrique
    Henrique avatar
    5 posts
    Member since:
    May 2013

    Posted 15 Oct 2013 Link to this post

    Hi everyone.

    I am trying to add a text and a hyperlink in the content of RadTileViewItem like this...


       HyperlinkButton hyperlink = new HyperlinkButton();
       hyperlink.NavigateUri = new Uri("http://www.uol.com.br", UriKind.Absolute);
       hyperlink.Content = "Uol";
       item.Content = "Test " + hyperlink;
       mainTileView.Items.Add(item);


    But it is not working well. Can anyone help me with this issue?


    BTY I am planning to add two hyperlinks, one for an image and another for a .doc

    Any help will be very welcomed.
  8. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 17 Oct 2013 Link to this post

    Hi Henrique,
    The problem is in this line of code:
    item.Content = "Test " + hyperlink;
    When you do this the hyperlink is used as string(instead of an UIElement) and that's why the content of your item becomes "Test System.Windows.Controls.HyperlinkButton". You should place the "Test" text in a TextBlock and then add it to some panel(Grid, Canvas, StackPanel and etc.) with the hyperlink:
    StackPanel sp = new StackPanel();
    sp.Children.Add(new TextBlock() { Text = "Test" });
    sp.Children.Add(hyperlink);
    item.Content = sp;
    mainTileView.Items.Add(item);
    Could you please try this out and if you have further questions feel free to ask.

    Regards,
    Zarko
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
DevCraft banner