question

ASH-1598 avatar image
0 Votes"
ASH-1598 asked LeonLu-MSFT commented

how get selectitem in viewmodel

Hi


how get selectitem in viewmodel

Picker is displaying the names And I want her ID in the view model

this code

view


    <Picker Style="{DynamicResource Picker}" Title="{x:Static Localize:LocalInquires.LBLChooseDep}" ItemsSource="{Binding FAQPickerStringList, Mode=TwoWay}"  SelectedItem="{Binding MySelectedItem , Mode=TwoWay}" HorizontalTextAlignment="Center" />


ViewModel


       private FAQModel _myselecteditem;
         public FAQModel MySelectedItem
         {
             get { return _myselecteditem; }
             set
             {
                 _myselecteditem = value;
                 OnPropertyChanged("MySelectedItem");
             }
         }

 .
 .
 .method .......(.....){
    if  ((MySelectedItem.site_id == null) {...........}
 }





dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

When you execute your method in the viewModel? You can create a button and bind a Command, create a command and add the method in your viewmodel. If you can get the MySelectedItem.

MySelectedItem.site_id == null will always return true, please change other analyzing conditions.

0 Votes 0 ·

0 Answers