SfPicker Context is not clear. How does it work? No good sample using MVVM

I just started using SfPicker and I love the UI how beautiful it is. I am not able to understand the purpose of it and unfortunately, i cant find a good example on your website.
So you have 2 modes Dialog and Default
this is my xamarin forms Picker

   <Picker  Grid.Row="3"  Title="{resx:Translate SelectChart,IsUpper=True}" ItemsSource="{Binding ChartCategories}" SelectedItem="{Binding SelectedChartCategory}"/>


Default Mode is working fine if I convert to one to one

    <syncfusion:SfPicker  x:Name="chartPicker"  Grid.Row="3" HeaderBackgroundColor="#2196F3" HeaderFontSize="20" HeaderTextColor="White" PickerMode="Default" ShowColumnHeader="False"  HeaderText="{resx:Translate SelectChart,IsUpper=True}" ItemsSource="{Binding ChartCategories}" SelectedItem="{Binding SelectedChartCategory}"/>
    

But I want my picker to be Dialog and xamarin forms picker has it as default visible like a button one you tap on it, it pops up. Apperantly using SfPicker we need to implement an extra button to make it IsOpen. AND most important is that SelectedItem Binding MUST work only OneWayToSource. If I bind it from code to xaml, it will return exception below. This means that when IsOpen=false, SfPicker is not in the visual treeview. Maybe it is even better regards to keep memory lower. 

Please correct me with above and if possible provide me a sample that works like Xamarin forms picker as code above. ViewModel code is as below

   public ObservableCollection<string> ChartCategories { get; set; }
    public ProgressPageModel()
        {
               ChartCategories = new ObservableCollection<string>() { Item1, Item2};
  
                RaisePropertyChanged("ChartCategories");
        }

System.NullReferenceException

Object reference not set to an instance of an object.

  at Com.Syncfusion.SfPicker.SfPicker.UpdateControl () [0x00a98] in <c85a453f98da42dca25494068894e253>:0 
  at Com.Syncfusion.SfPicker.SfPicker.set_PickerWidth (System.Double value) [0x0000f] in <c85a453f98da42dca25494068894e253>:0 
  at Syncfusion.SfPicker.XForms.Droid.SfPickerMapping.OnPickerPropertiesChanged (System.String propertyName, Syncfusion.SfPicker.XForms.SfPicker formsPicker, Com.Syncfusion.SfPicker.SfPicker nativePicker) [0x0065c] in <80ba8dcec06b45b9b4d5b0406b36dc64>:0 
  at Syncfusion.SfPicker.XForms.Droid.SfPickerRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00055] in <80ba8dcec06b45b9b4d5b0406b36dc64>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000b1] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:176 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:125 
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x00024] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\Platform.cs:314 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00044] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:97 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:231 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:76 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:385 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000ce] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:179 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:125 
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x00024] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\Platform.cs:314 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00044] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:97 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:231 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:76 


1 Reply

VA Vinnalan Aravazhi Syncfusion Team January 25, 2018 01:32 PM UTC

Hi Emil Alipiev,

Thanks for contacting Syncfusion support.

Query 1: SfPicker sample using MVVM

We have checked your requirement and we have created a sample based on your requirement in Dialog mode. Please find the sample from below link.

Sample: http://www.syncfusion.com/downloads/support/forum/135613/ze/Sample-1682524260903141118 

Query 2: NullreferenceException thrown while using Selectedtem

We have checked the reported issue from our side and we are able to reproduce the reported issue from our side.

Fix will be included our upcoming 2018 Vol 1 release, which will be rolled out by the mid of February.

Regards,
Vinnalan K A.
 


Loader.
Up arrow icon