How to set focus to a databounded TextBox in WPF when the selection change?

StackOverflow https://stackoverflow.com/questions/5427660

  •  11-11-2019
  •  | 
  •  

سؤال

I have a TextBox that is databound to a TreeView. If the selected element chnages the TextBox shows me the Name of it. What i want is, set the focus to the TextBox if the selection has changed and select the text in the TextBox.

Is this possible only with WPF and when, how?
(it is no problem with a event on the treeview "OnSelectionChange" but that's not the question ;-) )

<TextBox Name="textBoxTitel" DataContext="{Binding ElementName=treeView, Path=SelectedItem}" />

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top