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

Content re-loaded during each state transition

2 Answers 32 Views
TileView
This is a migrated thread and some comments may be shown as answers.
dxk240
Top achievements
Rank 1
dxk240 asked on 09 Nov 2011, 03:13 PM
When using the RadFluidContentControl to manage state transitions inside of a TileView, I just noticed that the actual content is reloaded (meaning that the UserControl Loaded event is fired) every time the state is changed. This has a negative impact on performance because the UserControl will trigger binding every time the state changes. Especially in cases where the UserControl has a lot of data bound to it. Could you offer any guidance on how this could be avoided? I understand that RadFluidContentControl inherits from the ContentControl which has the same behavior (which in many cases is desired since one is explicitly changing the content of the control). However, in case of a TileView, the already loaded content is not changing all the time, it should just be switching between the different states (large, small, restored).

Any help would be appreciated.

2 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 14 Nov 2011, 02:02 PM
Hello Dxk240,
As you've noticed the RadFluidContentControl uses a ContentControl (it actually uses a RadTransitionControl, but it inherits from a ContentControl) and it just changes it's content with some animation. Unfortunately there's no easy way to workaround the default behavior of the ContentControl (the reloading of the usercontrols). You can try to move most of the logic of your usercontrols inside the constructor so that it won't be executed on every reload or you can try simulate an RadFluidContentControl with something like this:
XAML:
<telerik:RadTileView x:Name="myTileView"
                      MinimizedColumnWidth="250"
                      TileStateChanged="RadTileView_TileStateChanged">
    <telerik:RadTileView.ContentTemplate>
        <DataTemplate>
            <Grid>
                <local:FirstUserControl Visibility="Collapsed" />
                <local:SecondUserControl />
                <local:ThirdUserControl Visibility="Collapsed" />
            </Grid>
        </DataTemplate>
    </telerik:RadTileView.ContentTemplate>
</telerik:RadTileView>
C#:
private void RadTileView_TileStateChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var container = e.OriginalSource as RadTileViewItem;
    if (container != null)
    {
        var firstControl = container.ChildrenOfType<FirstUserControl>().FirstOrDefault();
        var secondControl = container.ChildrenOfType<SecondUserControl>().FirstOrDefault();
        var thirdControl = container.ChildrenOfType<ThirdUserControl>().FirstOrDefault();
 
        switch (container.TileState)
        {
            case TileViewItemState.Restored:
                firstControl.Visibility = System.Windows.Visibility.Collapsed;
                secondControl.Visibility = System.Windows.Visibility.Visible;
                thirdControl.Visibility = System.Windows.Visibility.Collapsed;
                break;
            case TileViewItemState.Maximized:
                firstControl.Visibility = System.Windows.Visibility.Collapsed;
                secondControl.Visibility = System.Windows.Visibility.Collapsed;
                thirdControl.Visibility = System.Windows.Visibility.Visible;
                break;
            case TileViewItemState.Minimized:
                firstControl.Visibility = System.Windows.Visibility.Visible;
                secondControl.Visibility = System.Windows.Visibility.Collapsed;
                thirdControl.Visibility = System.Windows.Visibility.Collapsed;
                break;
            default:
                break;
        }
    }
}
but you'll lose the animations.
If you have more questions please feel free to ask.

Regards,
Zarko
the Telerik team

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

0
dxk240
Top achievements
Rank 1
answered on 15 Nov 2011, 04:03 PM
Zarko,
    Thank you for your reply. I was afraid what your workaround will consist of. Thank you anyways.
Tags
TileView
Asked by
dxk240
Top achievements
Rank 1
Answers by
Zarko
Telerik team
dxk240
Top achievements
Rank 1
Share this question
or