LosManos
LosManos

Reputation: 7692

WPF focus row of datagrid with only XAML

I can set the focus with only XAML to a Datagrid.
It eludes me how (if possible at all) how to set focus to the first row with only XAML.

My (shortened) XAML:

<Window x:Class="WhatIsInTheBarnBooth.MainWindow"
    ...
    FocusManager.FocusedElement="{Binding ElementName=grdData}">
</Window>

<DataGrid Name="grdData">
    ...
</DataGrid>

Upvotes: 3

Views: 1078

Answers (1)

Rohit
Rohit

Reputation: 10226

Can you try....

FocusManager.FocusedElement="{Binding ElementName=myDataGrid}"

and

<DataGrid Name="grdData" SelectedIndex="0">
    ...
</DataGrid>

Upvotes: 1

Related Questions