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

Bug Report (2010_Q3) null reference

7 Answers 64 Views
TileView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex Fan
Top achievements
Rank 1
Alex Fan asked on 12 Jan 2011, 06:10 AM
Hi

please try this, 

<UserControl
    x:Class="TestSilverlightApplication.MainPage1"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" xmlns:TestSilverlightApplication="clr-namespace:TestSilverlightApplication" mc:Ignorable="d" d:DesignHeight="435" d:DesignWidth="613">
    <UserControl.Resources>
        <TestSilverlightApplication:MainViewModel x:Key="MainViewModel"/>
         
        <Controls:ContainerBindingCollection x:Key="ContainerBindingCollection">
            <Controls:ContainerBinding PropertyName="TileState"
                   Binding="{Binding TileState, Mode=TwoWay}" />
        </Controls:ContainerBindingCollection>
        <DataTemplate x:Key="ItemTemplate" Controls:ContainerBinding.ContainerBindings="{StaticResource ContainerBindingCollection}">
            <TextBlock Text="{Binding Path=Header}"/>
        </DataTemplate>
    </UserControl.Resources>
 
    <Grid x:Name="LayoutRoot" Background="White" DataContext="{StaticResource MainViewModel}">
        <telerik:RadTileView ItemsSource="{Binding Path=TileViewModels}" ItemTemplate="{StaticResource ItemTemplate}"/>
    </Grid>
</UserControl>


c#
using System.Collections.Generic;
using System.Windows.Controls;
 
namespace TestSilverlightApplication
{
    using Telerik.Windows.Controls;
    using ViewModelBase = GalaSoft.MvvmLight.ViewModelBase;
 
    public partial class MainPage1 : UserControl
    {
        public MainPage1()
        {
            InitializeComponent();
        }
    }
 
    public class MainViewModel :ViewModelBase
    {
        public MainViewModel()
        {
            TileViewModels = new List<TileViewModel>
                              {
                                  new TileViewModel() { Header = "h1", SmallContent = "small1", Content = "normal1", LargeContent = "large1", TileState = TileViewItemState.Maximized},
                                  new TileViewModel() { Header = "h2", SmallContent = "small2", Content = "normal2", LargeContent = "large2"},
                              };
        }
 
        public List<TileViewModel> TileViewModels { get; set; }
    }
 
    public class TileViewModel : ViewModelBase
    {
        public string Header { get; set; }
        public string SmallContent { get; set; }
        public string Content { get; set; }
        public string LargeContent { get; set; }
        public TileViewItemState TileState { get; set; }
    }
}

if you run it, u get null reference exception. the reason i guess is, when the first TileViewItem is created, it is trying to bind to TileState which is set to Max. This will trigger this first tile to maximize itself and also it will try to minimize second tile which have not been created yet.

Regards,
Alex

7 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 12 Jan 2011, 05:33 PM
Hi Alex Fan,

 Thank you for this bug report. I looked into it and really the problem is that when the first item's TileState is set to Maximized it tries to access the container of the second item which is still not generated.
I've updated your Telerik account and if you have further questions feel free to ask.

Regards,
Zarko
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Alex Fan
Top achievements
Rank 1
answered on 13 Jan 2011, 03:36 AM
Hi

Can I know when this will be fixed :) or maybe a work around will be good as well. Because I don't want to hardcode xaml for each tile and later on I will have to come back and refactor the code....

thanks

Regards
Alex Fan
0
Zarko
Telerik team
answered on 13 Jan 2011, 09:35 AM
Hi Alex Fan,

 Currently we're making a major refactoring on the TileView which will be ready for the Q1 2011 Beta and this bug will be fixed with that release.
For now the easiest work around is to handle the Loaded event of the TileView and set the MaximizedItem in it like that:

private void myTileView_Loaded(object sender, RoutedEventArgs e)
{
    this.myTileView.MaximizedItem = this.myTileView.Items[0];
}
If you have more questions don't hesitate to ask.

Kind regards,
Zarko
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Alex Fan
Top achievements
Rank 1
answered on 23 Feb 2011, 12:34 AM
Hi

We have upgraded our Telerik control to Q3 2010 sp1. Now we can bind the TileState property, but when you try to maximize any tile, it will quickly maximize itself, minimize all the rest tiles then all tiles will be set back to restored, which means you cannot maximize a tile once you have TileState property twoway bound to viewmodel.

Regards,
Alex
0
Zarko
Telerik team
answered on 25 Feb 2011, 09:25 AM
Hi Alex Fan,

 Unfortunately I wasn't able to reproduce your problem so could you please send us some more information (a project that reproduces the issue or some code snippets). Note that the Q1 2011 Beta is out now and there are major changes to the RadTIleView (including fix for the initial bug you reported) so you can try it out.

Best wishes,
Zarko
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Alex Fan
Top achievements
Rank 1
answered on 28 Feb 2011, 12:24 AM
Hi

Actually when i re-run my little test solution with Q3 version dlls, i find that this problem is not fixed in Q3. I still get the same exception. Did you test the same code that I posted before?

Regards
Alex
0
Zarko
Telerik team
answered on 28 Feb 2011, 11:22 AM
Hi Alex Fan,

 Yes your initial problem is not fixed in the Q3 release, but it is fixed in the Q1 Beta that we released last week. In the last three months the RadTileView was literally rewritten and I'll advise you to start using the new one because all known bugs are fixed in it and it has a couple of very nice new features.
If you need further assistance feel free to ask.

All the best,
Zarko
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TileView
Asked by
Alex Fan
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Alex Fan
Top achievements
Rank 1
Share this question
or