Get value for selected item in ListPicker

I have a listpicker that shows the names of the items. When selecting an item, I want to get the item ID for the selected item. How can i do this?

<toolkit:ListPicker x:Name="lstItem" 
                                            FullModeHeader="Item"
                                            SelectionMode="Single" 
                                            ItemsSource="{Binding getItems}"  
                                            ExpansionMode="FullscreenOnly"  
                                            Margin="12,5,10,0" 
                                            Grid.Row="0" 
                                            Grid.Column="1"

                                            Background="White"
                                            FontSize="21"
                                            Header="" 
                                            Foreground="Black"
                                            BorderThickness="0" Grid.ColumnSpan="2" SelectionChanged="lstItem_SelectionChanged"
                                     >
                            <toolkit:ListPicker.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Name}"  />                                        
                                </DataTemplate>                                    
                            </toolkit:ListPicker.ItemTemplate>
                            <toolkit:ListPicker.FullModeItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal" Margin="16 15 0 15">
                                        <TextBlock Text="{Binding Name}"
                                   Margin="0 0 0 0"
                                   FontSize="25" 
                                   FontFamily="{StaticResource PhoneFontFamilyLight}"/>
                                    </StackPanel>
                                </DataTemplate>
                            </toolkit:ListPicker.FullModeItemTemplate>
                        </toolkit:ListPicker>

      

In C # Code, I am binding as a listpicker. I bind this data directly to the list collector.

public ObservableCollection<Items> bindItems()
    {
        listItems.Clear();
        //int i = Common.intCustomerId; //&& btypes.ChqRtnPaymentNo == ""
        var itemlist = from DailyItemStock DailyItm in APPCommon.SFADB
                       join ItemMaster IM in APPCommon.SFADB on DailyItm.ItemMasterID equals IM.ID
                       where DailyItm.StockDate == System.DateTime.Today
                       select new
                       {
                           DailyItm.ItemMasterID,
                           DailyItm.BatchNo,
                           IM.Name
                       };

        listItems.Add(new Items() { ItemMasterID = 0, Name = "Select One" });
        foreach (var lists in itemlist)
        {
            listItems.Add(new Items()
            {
                ItemMasterID = lists.ItemMasterID,
                BatchNo = lists.BatchNo,
                Name = lists.Name,                  
            });
        }

        itemlist = null;
        return listItems;
    }

      

+3


source to share


2 answers


One of the possible ways:



Items selectedItem = (Items)lstItem.SelectedItem;
int id = selectedItem.ItemMasterID;

      

+3


source


to get the id number you have to create in the database.

Example



SHOP_ID ='4987bc1b-c0a8-6cb7-12f4-0243011f7099'

and ( debitor_type

is null

or debitor_type

in (CASE WHEN ( select techfund_debitor_enabled from impl_shop where shop_id='4987bc1b-c0a8-6cb7-12f4-0243011f7099'

)

0


source







All Articles