I am getting that value does not fall into range exception

2 posts, 0 answers
  1. Syed Asif
    Syed Asif avatar
    10 posts
    Member since:
    Nov 2009

    Posted 05 Jun 2013 Link to this post

    The code that you are seeing is part of and Education ERP product which is already in production. We recently decided to move our code to SL5 but when we changed the dll's from SL4 to SL5 (We have a licensed version of Telerik controls for SL4 and for SL5 we are using the trial version. Once we find things satisfactory we will buy license from you), the RadTreeView component stopped working and started giving the error that I mentioned previously. At present I am looking into how we can create a small demo app that can reproduce the same error. But it would definitely take some time. But meanwhile can you also check and let me know if it is some known issue? Or could it be some problem with the versioning etc

    <tileview:TileToFluideStateConverter x:Key="tileConverter" />

            <DataTemplate x:Key="ItemTemplate">

                <TextBlock Text="{Binding HeaderText}" />


            <DataTemplate x:Key="ContentTemplate">

                <telerik:RadFluidContentControl ContentChangeMode="Manual"TransitionDuration="0:0:.5"                    

                                      State="{Binding State, Converter={StaticResourcetileConverter}}">


                        <telerik:RadBusyIndicator IsBusy="{Binding Path=IsBusy}">

                            <ContentControl Content="{Binding Path=SmallContent}"/>




                        <telerik:RadBusyIndicator IsBusy="{Binding Path=IsBusy}">

                            <ContentControl Content="{Binding Path=NormalContent}"/>




                        <telerik:RadBusyIndicator IsBusy="{Binding Path=IsBusy}">

                            <ContentControl Content="{Binding Path=LargeContent}"/>







            <!--<ScrollViewer  HorizontalScrollBarVisibility="Auto"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto" Padding="0" BorderThickness="0">-->

            <telerik:RadTileView x:Name="tileView" 

                                     VerticalAlignment="Stretch" HorizontalAlignment="Stretch"




                                    ItemTemplate="{StaticResource ItemTemplate}"ContentTemplate="{StaticResource ContentTemplate}" ItemsSource="{Binding Path=RichParts}"





      void tileView_TileStateChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)


                RadTileViewItem item = e.OriginalSource as RadTileViewItem;

                if (item != null)


                    var viewmodel = ((RadFluidContentControl)item.Content).DataContext asIPhoenixBaseRichletView;

                    if (viewmodel != null)


                        viewmodel.State = item.TileState;




            void RichPartList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)


                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)




                        foreach (PhoenixBaseRichletView richlet in e.NewItems)


                            RadTileViewItem item = new RadTileViewItem();

                            item.Header = richlet.HeaderText;

                            var contentTemplate = this.Resources["ContentTemplate"] asDataTemplate;

                            var ctrl = contentTemplate.LoadContent() as RadFluidContentControl;

                            ctrl.DataContext = richlet;

                            item.Content = ctrl;




                    catch (Exception ex)


                        this.Error = ex;




  2. Zarko
    Zarko avatar
    755 posts

    Posted 06 Jun 2013 Link to this post

    Hi Syed,
    I'm not sure what the exact reason for this issue might be because I don't have all of you code but I noticed a couple of things:
    - you haven't registered the TileStateChanged event handler - TileStateChanged="tileView_TileStateChanged"
    - in your tileView_TileStateChanged handler you're trying to get the business object like this:
    var viewmodel = ((RadFluidContentControl)item.Content).DataContext as IPhoenixBaseRichletView;
    but you could do it like this:
    var viewmodel = this.tileView.ItemContainerGenerator.ItemFromContainer(item) as IPhoenixBaseRichletView;
    var viewmodel = item.Content as IPhoenixBaseRichletView;
    - in the RichPartList_CollectionChanged handler you're trying to add a new item directly to your tileView's items collection(this.tileView.Items.Add(item)) while you're using ItemsSouce(ItemsSource="{Binding Path=RichParts}") and this is not correct.
    I've used your code snippets to create a sample project and everything seems to work fine after this changes so could you please examine it and if you have further questions feel free to ask.


    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top