<Window x:Class="WpfApplication1.Junk" > xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > Title="Junk" Height="300" Width="300"> > <StackPanel> > <Button Height="23" HorizontalAlignment="Left" Margin="50,30,0,0" Name="button1" VerticalAlignment="Top" Width="75">Button</Button> > <TextBox Height="23" Margin="40,66,88,0" Name="txtPatternName" Text="{Binding Path=PatternName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Top" /> > <StackPanel> > <ListBox Height="65" Margin="59,0,120,45" Name="listBox1" VerticalAlignment="Bottom" SelectionChanged="listBox1_SelectionChanged" > > <ListBoxItem>One</ListBoxItem> > <ListBoxItem>Two</ListBoxItem> > <ListBoxItem>Three</ListBoxItem> > </ListBox> > </StackPanel> > </StackPanel> ></Window>with
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) > { > txtPatternName.Focus(); > }This seems to work fine - why did your code behave differently?
>>Hi, >> >>Actually after calling the "SetActivePattern" the control return to the Listview changed event and it retun to ListView. So again the Focus moved to ListView. To overcome u start the SetActivePattern function in a Dispatcher.Invoke or BeginInvoke with System Idle priority u get the focus in text pattern. See the sample below >> >>define a delegate >>private delegate void focus(HolePattern NewActivePattern); >> >>paste the below code inside the lvHolePatterns_SelectionChanged >> >>this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.SystemIdle, new focus(SetActivePattern), >>(HolePattern)lvSender.SelectedItem); >> >>Hope this helps >>Regards >>Anandakumar.R >>>>