0

I am setting selecteditem manually

public pageXXXX()
        {

            InitializeComponent();

            this.cargaLista();
        }

private void cargaLista()
{
    this.lPickTipo.SelectedItem = this.lPickTipo.Items.OfType<tipos>().First(i => i.tipo == varString);

    // here i load other data 
    //


}

Ok. Runs fine.

But my problem is that selectionchanged event is fire last, not when I set manually the SelectedItem

This is a problem for me. Because I run calc inside "SelectionChanged" event and I need to run calc when I selecteditem because other functions depend on this result

   private void lPickTipo_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                try
                {
                    if (this.lPickTipo.SelectedItem != null)
                    {
                        if (lPickTipo.SelectedIndex > -1)
                        {
                            this.calcularTotales();
                        }
                    }
                }
                catch (Exception EXC)
                { // CACTHING }

            }

Why is fire last? How I can solve this?

aco
  • 819
  • 4
  • 15
  • 32

1 Answers1

0

In that you can't change the order that system level events are raised you'll need to change your logic to account for what the platform does.
As you haven't provided any information on what you're actually basing on the selection or why it requires page (presumably) level events to be fired after the selection is changed it's hard to be more specific.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
  • Hi: "selectionchanged" is launched +1 time: 1st when i fill listpicker (ok) and (2nd or last) before to show the page. I dont understand this last launch...Why selectionchanged is firiring 2 times? if I create an example with a listpicker always happens this... – aco May 10 '12 at 14:22