Layout problem with PreservePositionWhenMaximized and dynamically added items

4 posts, 1 answers
  1. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 25 Jun 2012 Link to this post

    When the tile view has got PreservePositionWhenMaximized set to True, it would have a funny layout behaviour when new item is added to the view maximized.

    Below is simple test code to reproduce this, it looks ok when the first and second tile is added, but when the third tile is added, the minimized second tile is placed at the same position as the first minimized tile and covered it up:

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="26" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
         
        <Button Content="Add" Click="Button_Click" />
     
        <telerik:RadTileView Name="tileview" Grid.Row="1"
                             PreservePositionWhenMaximized="True"
                             MinimizedColumnWidth="300"
                             MinimizedRowHeight="45"/>
    </Grid>

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        tileview.Items.Add(new RadTileViewItem() { TileState = TileViewItemState.Maximized });
    }
  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 27 Jun 2012 Link to this post

    Hello,
    Thank you for the feedback! I logged this issue in your PITS under the name "Wrong layout when adding Maximized RadTileViewItems and PreservePositionWhenMaximized is set to True" and it'll be ready for tracking and voting tomorrow the latest.
    As for now I can advice you to add maximized items like this:
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var newItem = new RadTileViewItem() { TileState = TileViewItemState.Maximized, Header = this.tileview.Items.Count };
        this.tileview.Items.Add(newItem);
        this.tileview.MaximizedItem = newItem;
    }
    I've updated you telerik account and if you have further questions please feel free to ask.

    All the best,
    Zarko
    the Telerik team

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

  3. UI for WPF is Visual Studio 2017 Ready
  4. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 27 Jun 2012 Link to this post

    I'm afraid that the temporary solution you suggested isn't going to work for me as in my real project, I am using MVVM and the tile items is bind to a collection. The code in the OP is just for demonstration of the issue.

    Anyway, maybe I will just live without PreservePositionWhenMaximized  for now until it's fixed.
  5. Answer
    Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 29 Jun 2012 Link to this post

    Hello Wenrong,
    You can still use this workaround but you'll have to also bind the MaximizedItem of the RadTileView:
    <telerik:RadTileView Name="tileview"
                     ItemsSource="{Binding Items}"
                     MaximizedItem="{Binding MaximizedItem, Mode=TwoWay}"
                     PreservePositionWhenMaximized="True">
    and
    internal void AddItem()
    {
        var newItem = new MyItem() { Name = "Item " + this.Items.Count };
        this.Items.Add(newItem);
        this.MaximizedItem = newItem;
    }
    If need further assistance please feel free to ask.

    Kind regards,
    Zarko
    the Telerik team

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

Back to Top