0
我正在努力從聚焦文本框存在於DataGrid中探頭。 真正的場景爲:專注於DataGrid中存在的文本框
我有一個數據網格中,我有數據網格的3 columns.The第三列包含2個不同的控制: - 一個是組合框,而另一個是文本框(兩者都是在相同的RowDefinition和ColumnDefinition)。 假設我有3行,所以想要的是當我在文本框中輸入一個文本(出現在第一行),然後按ENTER然後焦點應該移動到下一行TEXTBOX,但是現在發生的是它將整個單元格(其中包含ComboBox和TextBox)的DataGrid。
我試過幾個例子:
private void dg_PreviewKeyDown(object sender, KeyEventArgs e)
{
var uie = e.OriginalSource as UIElement;
if (e.Key == Key.Enter)
{
e.Handled = true;
uie.MoveFocus(
new TraversalRequest(FocusNavigationDirection.Next));
}
}
,但它的下一個單元格是一樣既ComoBox和TextBox聚焦小區中移動焦點。
我跟着這個鏈接太多,但它幫助力:
http://madprops.org/blog/enter-to-tab-as-an-attached-property/
幫我出Guys..Focusing控制總是我的錯誤。
看看http://stackoverflow.com/questions/746069/wpf-datagrid-datagridtemplatecolumn-tab-focus-issue – Schuere
答案被標記是沒有幫助的..Sorry – Vishal