SelectionChanged – pustekuchens Blog https://blog.bur-k.de In der Welt der Bits und Bytes Mon, 11 Jul 2011 16:58:00 +0000 de-DE hourly 1 https://wordpress.org/?v=6.4.2 Set SelectedIndex in a SelectionChanged Event https://blog.bur-k.de/?p=40 https://blog.bur-k.de/?p=40#respond Mon, 11 Jul 2011 16:58:00 +0000 http://pustekuchen.xn--burkfrulein-q8a.de/?p=40 Weiterlesen →]]> Hello folks,

today i got a wierd problem in my Silverlight Application. I had two Comboboxes, i wanted to change the items of the second Combobox, when i select a value in the first Combobox.

But the second Combobox still showed another value. After spending some time with google i found this topic.

The solution to that Problem is the following.

private void cmbOne_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    cmbTwo.Dispatcher.BeginInvoke(new Action(() => { cmbTwo.SelectedIndex = 0; }));
}

The BeginInvoke Method executes the specified delegate asynchronously with the specified arguments on the thread that the Dispatcher was created on.

Now its works how it should. I hope it will help someone :)

]]>
https://blog.bur-k.de/?feed=rss2&p=40 0