Search code examples
c#windows-phone-7windows-phone-8toolkitwindows-phone-toolkit

Why is ToolKit-ListPicker being stuck?


I have been using Toolkit-Windows Phone 8 for List Picker as a Combo Box Option selection control, however I have experienced at certain times list picker control is not closing its pop up window (Full screen mode mostly). Since List Picker handles back key press event, it's not working with the app. Also, if you have handled your app resume then you are stuck at this window and I have checked which URL application the application is navigating to. Then I found the following URL from RootFrame_Navigating Method.

Microsoft.Phone.Controls.Toolkit;component/ListPicker/ListPickerPage.xaml

Furthermore, I have tried to recreate this error and i find sometimes impossible to regenerate. Therefore I would like to know that anyone experience this error and What would be the solution for this? Thanks

enter image description here

Code related with Listpicker

<toolkit:ListPicker x:Name="cmbinvoice"  
                                            ItemsSource="{Binding Path=listinvoices}"                                              
                                            Grid.Column ="0" 
                                            Grid.ColumnSpan="2"   
                                            RenderTransformOrigin="0.5,0.5" 
                                            ExpansionMode="FullscreenOnly" 
                                            Foreground="Black" 
                                            Background="White"  
                            FullModeHeader="Invoice"
                                            Margin="15,90,10,-123" FontWeight="Bold" TabIndex="2147483645" Tag="" SelectionChanged="cmbinvoice_SelectionChanged"    >
                <toolkit:ListPicker.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding invoiceno}" />
                    </DataTemplate>
                </toolkit:ListPicker.ItemTemplate>
                <toolkit:ListPicker.FullModeItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="16 15 0 15"  Orientation="Horizontal" >
                            <TextBlock Text="{Binding invoiceno}"
                                       Margin="0 0 0 0"
                                       FontSize="30" 
                                       FontFamily="{StaticResource PhoneFontFamilyLight}"/>
                        </StackPanel>
                    </DataTemplate>
                </toolkit:ListPicker.FullModeItemTemplate>
            </toolkit:ListPicker>

Code Behind

     cmbinvoice.ItemsSource = vm.invoiceh; //When the Page Starts 

private void cmbinvoice_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            invoiceno = "";
            vm.invoiced.Clear();
            vm.invoicep.Clear();
            if (cmbinvoice.SelectedIndex != -1 && vm.invoiceh[cmbinvoice.SelectedIndex].invoiceno != "Select One")
            {
                invoiceno = vm.invoiceh[cmbinvoice.SelectedIndex].invoiceno;
                vm.cancelphase2setup(invoiceno);
                invpayments.ItemsSource = vm.invoicep;
                invitems.ItemsSource = vm.invoiced;
                lblcustomer.Text = vm.invoiceh[cmbinvoice.SelectedIndex].customer;
                lbltotal.Text = vm.invoiceh[cmbinvoice.SelectedIndex].amount.ToString("N2");
                lbldate.Text = string.Format("{0:dd-MMM-yyyy}", vm.invoiceh[cmbinvoice.SelectedIndex].invoicedate.Date);
            }
            else
            {
                lbldate.Text = "";
                lbltotal.Text = "";
                lblcustomer.Text = "";
            }
        }

ViewModel Code

When the Page Starts

public void cancelsetup()
        {
            int customer = APPCommon.customerid;
            //var query = from InvoiceHeader oh in APPCommon.SFADB where oh.CustomerID == customer && oh.Deleted == false && oh.InvoiceDate == APPCommon.TransactionDate select oh;

            invoiceh.Add(new InvHead() { customerid = 0, amount = 0, customer = "", invoicedate = APPCommon.TransactionDate, invoiceno = "Select One" });

            foreach (string x in APPCommon.invnos)
                foreach (InvoiceHeader oh in from InvoiceHeader oh in APPCommon.SFADB where oh.CustomerID == customer && oh.Deleted == false && oh.InvoiceDate == APPCommon.TransactionDate && oh.InvoiceNo == x orderby oh.InvoiceNo descending select oh)
                    if (!(from OutstandingSettlementsDetail O in APPCommon.SFADB where O.InvoiceNo == oh.InvoiceNo select O).Any())
                        invoiceh.Add(new InvHead() { customerid = oh.CustomerID, amount = oh.NetAmount, customer = APPCommon.CustomerName, invoicedate = oh.InvoiceDate, invoiceno = oh.InvoiceNo });
        }

When You Select Listpicker

public void cancelphase2setup(string invoiceno)
        {
            if (invoiceno == "") return;

            foreach (InvoicePayment ip in from InvoicePayment ip in APPCommon.SFADB where ip.InvoiceNo == invoiceno select ip)
            {
                string pt = (from PaymentType p in APPCommon.SFADB where p.ID == ip.PaymentTypeID select p.Name).FirstOrDefault();
                invoicep.Add(new InvPayment() { Amount = ip.Amount, invoiceno = ip.InvoiceNo, invpaymentno = ip.InvoicePaymentNo, type = pt, typeid = ip.PaymentTypeID });
                pt = null;
            }

            foreach (InvoiceDetail id in from InvoiceDetail id in APPCommon.SFADB where id.InvoiceNo == invoiceno select id)
            {
                string im = (from ItemMaster i in APPCommon.SFADB where i.ID == id.ItemMasterID select i.Name).FirstOrDefault();
                invoiced.Add(new InvDetail() { BatchNo=id.BatchNo, DiscountPercentage = id.DiscountPerc, invoiceno = id.InvoiceNo, ItemMasterID = id.ItemMasterID, ItemMasterName = im, NBT = id.NBTPerc, Quantity = id.Qty, Total = id.NetAmount, UnitPrice = id.Price, VAT = id.VATPerc });
                im = null;
            }

            string key = (from ExchangeHeader e in APPCommon.SFADB where e.InvoiceNo == invoiceno select e.ExchangeNo).FirstOrDefault();

            if (key != null)
                foreach (var e in from ExchangeDetail e in APPCommon.SFADB where e.ExchangeNo == key select e)
                {
                    string im = (from ItemMaster i in APPCommon.SFADB where i.ID == e.ItemMasterID select i.Name).FirstOrDefault();
                    invoiced.Add(new InvDetail() { exchange = true, rtn = false, BatchNo = e.BatchNo, DiscountPercentage = 0, invoiceno = invoiceno, ItemMasterID = e.ItemMasterID, ItemMasterName = im, NBT = 0, Quantity = (double)e.Qty, Total = (decimal)e.NetAmount, UnitPrice = (decimal)e.UnitPrice, VAT = 0 });
                    im = null;
                }

            key = (from ReturnHeader e in APPCommon.SFADB where e.InvoiceNo == invoiceno select e.ReturnNo).FirstOrDefault();

            if (key != null)
                foreach (var e in from ReturnDetail e in APPCommon.SFADB where e.ReturnNo == key select e)
                {
                    string im = (from ItemMaster i in APPCommon.SFADB where i.ID == e.ItemMasterID select i.Name).FirstOrDefault();
                    invoiced.Add(new InvDetail() { exchange = false, rtn = true, BatchNo = e.BatchNo, DiscountPercentage = 0, invoiceno = invoiceno, ItemMasterID = e.ItemMasterID, ItemMasterName = im, NBT = 0, Quantity = (double)e.Qty, Total = (decimal)e.NetAmount, UnitPrice = (decimal)e.Price, VAT = 0 });
                    im = null;
                }
        }

Solution

  • There is an error with the toolkit, It cant be fixed unless you are the developer.