RadListPicker - probelm with binnding

0 Answers 67 Views
ListPicker
Daniel
Top achievements
Rank 1
Silver
Bronze
Daniel asked on 16 Mar 2022, 12:10 PM | edited on 16 Mar 2022, 12:10 PM

Hi,

There is problem with binding.


   <ContentView.BindingContext>
        <local:HistoryViewModel/>
    </ContentView.BindingContext>

<telerikInput:RadListPicker x:Name="typeListPicker" Placeholder="Select Type" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" HeightRequest="40" WidthRequest="200" Margin="5" ItemsSource="{Binding TypesItems}" DisplayMemberPath="Value" SelectedItem="{Binding Types, Mode=TwoWay}"><telerikInput:RadListPicker.ItemTemplate><DataTemplate><Label Text="{Binding Value}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/></DataTemplate></telerikInput:RadListPicker.ItemTemplate></telerikInput:RadListPicker>


 private SchedulerTypeItem _types; 
  public HistoryViewModel()
        {
     
InitTypesItem();
}

   private void InitTypesItem()
        {
            TypesItems = new ObservableCollection<TypesItem>()

            {
              new TypesItem { Value = "Push" },
              new TypesItem { Value = "Pull" },
             };
        }

  public SchedulerTypeItem Types
        {
            get
            {
                return _types;
            }
            set
            {
                if (_types != value)
                {
                    _types = value;
                    OnPropertyChanged();
                }
            }
        }

Commad
======
if (Types != null && !string.IsNullOrEmpty(Types.Value)) // throw init innitlized exception
            {
                historyReport = new ObservableCollection<HistoryReport>(historyReport.Where(hr => hr.Type == Types.Value));
            }


 

 

No answers yet. Maybe you can help?

Tags
ListPicker
Asked by
Daniel
Top achievements
Rank 1
Silver
Bronze
Share this question
or