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

Reseting SelectedItem ou ItemsSource

11 Answers 100 Views
SlideView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Cristovao
Top achievements
Rank 1
Cristovao asked on 21 May 2013, 11:02 PM
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

11 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 22 May 2013, 07:03 AM
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.
0
Cristovao
Top achievements
Rank 1
answered on 22 May 2013, 07:12 AM
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.

0
Todor
Telerik team
answered on 22 May 2013, 07:42 AM
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.
0
Cristovao
Top achievements
Rank 1
answered on 22 May 2013, 08:18 AM
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
0
Todor
Telerik team
answered on 24 May 2013, 07:58 AM
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.
0
Eng
Top achievements
Rank 1
answered on 01 Feb 2014, 03:04 PM
i bind the selected item from mvvm and it always be null and take the first item always 
0
Kiril Stanoev
Telerik team
answered on 05 Feb 2014, 04:10 PM
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.
0
Eng
Top achievements
Rank 1
answered on 07 Feb 2014, 08:15 PM
  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>

0
Eng
Top achievements
Rank 1
answered on 07 Feb 2014, 08:16 PM
the selected item in slideview is always null so it display the first item in slide view 
0
Kiril Stanoev
Telerik team
answered on 10 Feb 2014, 08:44 AM
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.
0
Eng
Top achievements
Rank 1
answered on 12 Feb 2014, 07:00 PM
Thanks Kiril
Tags
SlideView
Asked by
Cristovao
Top achievements
Rank 1
Answers by
Todor
Telerik team
Cristovao
Top achievements
Rank 1
Eng
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Share this question
or