Getting Exception when hiding all tiles "Sequence contains no elements"

5 posts, 0 answers
  1. Muhammad Ummar
    Muhammad Ummar avatar
    26 posts
    Member since:
    Jul 2012

    Posted 25 Mar 2013 Link to this post

    I am using RadTiles in my project, and as a requirement I need to implement enable/disable of tiles (means visible/hidden respectively), But I am getting strange exception in My TileViewPanel.cs. "Sequence contains no elements", when I set visibility of all tiles to false. I have tried with latest assemblies of Telerik i.e. Q1 2013. but no difference.

    private void Button_Click(object sender, RoutedEventArgs e)
            {
                
    try
                {
                    
    for (int i = 0; i < 3;i++ )
                        ((RadTileViewItem)firstTileView.Items[i]).Visibility = System.Windows.Visibility.Hidden;
                }
                
    catch (Exception ex)
                {
                    
    throw ex;
                }
               
            }

    When I press the Hide 1 button as in screen shot, I get the following exception.

       at System.Linq.Enumerable.Average(IEnumerable`1 source)
       at System.Linq.Enumerable.Average[TSource](IEnumerable`1 source, Func`2 selector)
       at Telerik.Windows.Controls.TileViewPanel.TryToRecalculatePositonsAndOffsets() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\TileView\TileViewPanel.cs:line 1120
       at Telerik.Windows.Controls.TileViewPanel.MeasureRestoredChildren(Boolean isVirtualized, Int32 row) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\TileView\TileViewPanel.cs:line 1087
       at Telerik.Windows.Controls.TileViewPanel.MeasureItems() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\TileView\TileViewPanel.cs:line 979
       at Telerik.Windows.Controls.TileViewPanel.MeasureOverride(Size availableSize) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\TileView\TileViewPanel.cs:line 398
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at TileViewDnD.App.Main() in C:\Users\m.iqbal\Desktop\362970_TileViewDnD\362970_TileViewDnD\362970_TileViewDnD\TileViewDnD\TileViewDnD\obj\x86\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


    Please help me out?
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 27 Mar 2013 Link to this post

    Hello Muhammad,

    I tried to reproduce your issue with our latest official release and it seems that the code works as expected on our side. Can you please take a look at the attached project and see if I missed something? In case that I missed some details please change the project correspondingly and send it back to me.

    Thank you for your cooperation.

    Regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Muhammad Ummar
    Muhammad Ummar avatar
    26 posts
    Member since:
    Jul 2012

    Posted 28 Mar 2013 Link to this post

    Hello Pavel,

    Thanks for your reply and sending me the demo project. As far as your demo project is concerned it is working fine on my end as well. But as soon as I add the attached properties "telerik:TileViewPanel.IsColumnsShrinkEnabled="True"" and "telerik:TileViewPanel.IsRowsShrinkEnabled="True"" to TileView, it stops working as well.I have updated your demo project. But unfortunately I can't attach .zip or .rar file here due to my account limitations. But I am adding the updated .XAML for "MainWindow.xaml". You can try it yourself.

    <Window x:Class="TileView_WPF.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            Title="MainWindow">

    <
    Grid Background="White">
    <Grid.RowDefinitions>
    <RowDefinition />
    <RowDefinition />
    </Grid.RowDefinitions>
            <telerik:RadTileView x:Name="xTileView" telerik:TileViewPanel.IsColumnsShrinkEnabled="True" telerik:TileViewPanel.IsRowsShrinkEnabled="True">
    <telerik:RadTileViewItem Content="Item 1 Content" Header="Item 1" />
    <telerik:RadTileViewItem Content="Item 2 Content" Header="Item 2" />
    <telerik:RadTileViewItem Content="Item 3 Content" Header="Item 3" />
    </telerik:RadTileView>
    <Button Width="80" Grid.Row="1" Height="25" Click="Button_Click" Content="Hide1" />
    </Grid>
    </Window>

    I haven't made any other change that that. and as per my scenario I can't remove those 2 attached properties.

    Any idea?

  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 01 Apr 2013 Link to this post

    Hi Muhammad,

    Unfortunately this is a bug in the RadTileView control. This is why I logged it in our PITS and you can follow it and vote for it here. I also updated your Telerik account.

    Meanwhile, as a workaround you can try removing the attached properties before setting the Visibility property of the last RadTileView item to Collapsed and set them back when one item is visualized.

    Please accept our apologies for the inconvenience caused.

    Regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Muhammad Ummar
    Muhammad Ummar avatar
    26 posts
    Member since:
    Jul 2012

    Posted 02 Apr 2013 Link to this post

    Thanks Pavel, for adding this to PITS. However as a workaround I have set the Opacity of last tile to "0" rather than setting the Visibility to Collapsed. and it worked fine.

    Regards.
    Ummar
Back to Top
UI for WPF is Visual Studio 2017 Ready