Reseting SelectedItem ou ItemsSource

12 posts, 0 answers
  1. Cristovao
    Cristovao avatar
    24 posts
    Member since:
    Jun 2012

    Posted 21 May 2013 Link to this post

    I'm binding my slideview
    <telerikPrimitives:RadSlideView x:Name="radSlideView"
                                              Grid.Row="0"
                                              Grid.RowSpan="2"
                                              ItemsSource="{Binding Items}"
                                              SelectedItem="{Binding DataContext.SelectedPage, ElementName=LayoutRoot,Mode=TwoWay}"
                                              IsLoopingEnabled="True"
                                              ItemTemplateSelector="{StaticResource templateSelector}"
                                              AdjacentItemsPreviewMode="Next">
                  <telerikPrimitives:RadSlideView.ItemTemplate>
                      <DataTemplate/>
                  </telerikPrimitives:RadSlideView.ItemTemplate>
                
              </telerikPrimitives:RadSlideView>

    But if I try to reset the SelecedItem to Null on my ViewModel I get an error.. or even I try to clear my Items I get an error....
    I'm using MVVM Light ..

    Any thoughs?








    111
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 22 May 2013 Link to this post

    Hi Cristovao,

    Thank you for writing.

    RadSlideView's SelectedItem is the one that is currently displayed. The SelectedItem gets automatically set to the first item of the collection and as long as there are items, one of them is always visible and is "selected". Therefore, if you want to "reset" the SlideView, you should set your property to the first item and not to null.

    I hope this information help. Let me know if you need additional assistance.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Cristovao
    Cristovao avatar
    24 posts
    Member since:
    Jun 2012

    Posted 22 May 2013 Link to this post

    I understand that but  there's a scenario that it's not applicable.

    1) You are on a list of item 
    2) Taping one element you'll navigate to your details in a form of a page with a SlideView
    This is ALL done via MVVM binding a ObservableCollection<Page> to the ItemsSource and a Page to the SelectedItem 
    3) You press back
    4) you select another item from you list navigating to the detais,
    5) you MUST clear you  ObservableCollection<Page> before loading the Pages from the selected Item from the previous list.
    Here I get and exception that the SelectedPage that is bindind to the SelectedItem Cannot be null

    thank you.

  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 22 May 2013 Link to this post

    Hi Cristovao,

    I agree that you may need to clear the collection and this is why you shouldn't get an exception when trying to clear the ItemsSource. The expected exception is when you do have items, but you try to set the selected item to null.

    If you get an exception even without setting the SelectedItem to null, please open a new support ticket with attached sample project that we can use to reproduce the issue and we will assist you further.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  6. Cristovao
    Cristovao avatar
    24 posts
    Member since:
    Jun 2012

    Posted 22 May 2013 Link to this post

    I've opened a Ticket..

    because all I do is 

      Items = new ObservableCollection<Models.UI.GuideBasePage>();
    



    and if it's the second time I open the page .. it throws an exception


    Thanks
  7. Todor
    Admin
    Todor avatar
    778 posts

    Posted 24 May 2013 Link to this post

    Hi Cristovao,

    From our communication in the support ticket, it seems like you have managed to clear the items in the view model before SlideView is loaded. This way it is bound to the correct collection from the very beginning and there is no present issue. This thread is considered closed.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  8. Eng
    Eng avatar
    21 posts
    Member since:
    Jun 2013

    Posted 01 Feb 2014 in reply to Todor Link to this post

    i bind the selected item from mvvm and it always be null and take the first item always 
  9. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 05 Feb 2014 Link to this post

    Hi Eng,

    Could you please elaborate a bit more on the issue you're experiencing? Also, it would be great if you can send us a sample project reproducing the issue.

    Regards,
    Kiril Stanoev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
  10. Eng
    Eng avatar
    21 posts
    Member since:
    Jun 2013

    Posted 07 Feb 2014 in reply to Kiril Stanoev Link to this post

      i have a list of favorites when i navigate to full screen page i want to set the selected item from viewmodel 
      <DataTemplate x:Key="RadSlideViewItemTemplate">
                    <telerikSlideView:PanAndZoomImage Stretch="Uniform" Source="{Binding ImagePath, Converter={StaticResource IsoImageCoverter}}"  ZoomMode="Free">
                        <telerikSlideView:PanAndZoomImage.BusyIndicatorStyle>
                            <Style TargetType="telerikPrimitives:RadBusyIndicator">
                                <Setter Property="AnimationStyle" Value="AnimationStyle9"/>
                            </Style>
                        </telerikSlideView:PanAndZoomImage.BusyIndicatorStyle>
                    </telerikSlideView:PanAndZoomImage>
                </DataTemplate>
    <telerikPrimitives:RadSlideView x:Name="slideView"  IsLoopingEnabled="False"
                                            ItemsSource="{Binding FavouritesList}" 
                                            
                                            SelectedItem="{Binding selectedItem,Mode=TwoWay}"
                                           
                                            ItemTemplate="{StaticResource RadSlideViewItemTemplate}"
                                             >
                
            </telerikPrimitives:RadSlideView>

  11. Eng
    Eng avatar
    21 posts
    Member since:
    Jun 2013

    Posted 07 Feb 2014 in reply to Eng Link to this post

    the selected item in slideview is always null so it display the first item in slide view 
  12. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 10 Feb 2014 Link to this post

    Hello Eng,

    Please examine the attached project and let us know if it helps.

    Regards,
    Kiril Stanoev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
  13. Eng
    Eng avatar
    21 posts
    Member since:
    Jun 2013

    Posted 12 Feb 2014 in reply to Kiril Stanoev Link to this post

    Thanks Kiril
Back to Top
DevCraft banner