How can i display selected cell on datagrid, when modal is displayed

Lawniczak, Kamil 1 Reputation point
2020-08-03T08:51:36.157+00:00

Hello,

We have a Datagrid, which display a Modal window for each cell(a cell is product o x features filled inside modal). We have a requirement that when modal is displayed, the datagrid should highlit corresponding cell. The problem which we have is, that even inactive selected cell is not working in this case. Any Help?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,691 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. DaisyTian-1203 11,616 Reputation points
    2020-08-04T03:03:45.35+00:00

    You can add GotFocus and LostFocus for the DataGridCell like below show:

     <DataGrid.CellStyle>  
                        <Style TargetType="{x:Type DataGridCell}">  
                            <EventSetter Event="GotFocus" Handler="myDataGridMain_GotFocus" ></EventSetter>  
                            <EventSetter Event="LostFocus" Handler="myDataGridMain_LostFocus"></EventSetter>  
                        </Style>  
                    </DataGrid.CellStyle>  
    

    In the cs code add the below events:

    15354-capture.png

    0 comments No comments