Highlight Row when hover mouse on cell whose state IsEnable = False

Posted by: duc.pham on 12 November 2018, 5:58 pm EST

    • Post Options:
    • Link

    Posted 12 November 2018, 5:58 pm EST

    Hi,

    How to I can Highlight Row when hover mouse on cell whose state IsEnable = False. I have an example bellow

    Thank you

    WPFBlankApp1.zip

  • Posted 14 November 2018, 8:49 pm EST

    Hello,

    Thank you for sharing the sample. I can observe that for the disabled column, hovering mouse does not highlight the row.

    However, as per my understanding this is by-design since Microsoft documents “Elements that are not enabled do not participate in hit testing or focus and therefore will not be sources of input events.”. And because of this grid’s MouseMove event does not get triggered for this column to highlight the row.

    To workaround this, I would suggest you to set the IsEnabled property of the TextBlocks (in CellTemplate, CellEditingTemplate) rather than setting it for the DataGridCellPresenter

    I modified the application and attached here for your reference.

    Microsoft documentation (See Remarks section): https://docs.microsoft.com/en-us/dotnet/api/system.windows.uielement.isenabled?redirectedfrom=MSDN&view=netframework-4.7.2#System_Windows_UIElement_IsEnabled

    Do let me know if you need any further assistance.

    Thanks,

    Ruchir

    HighlightRow_IsEnabled.zip

  • Posted 14 November 2018, 10:02 pm EST

    Hello

    Thank you for your respond!

    However,the thing I really need is the one same as the default of WPF when I set the IsEnable = “False” status of the DatagridCell in the ResourceDictionary.xaml file, it’s still highlighted when the hover mouse on Row. Can you help us issue?

    I have an example bellow about default of WPF

    Thanks,

    WpfDataGridStyle.zip

  • Posted 16 November 2018, 12:46 am EST - Updated 4 October 2022, 12:10 am EST

    Hi,

    Thank you for sharing the file. I have further modified my application (Observe the LoaderRowPresenter event).

    Could you please try the sample and see if it meets your requirement.

    Thanks,

    Ruchir

    WPFApp_Mod.zip

  • Posted 18 November 2018, 3:29 pm EST - Updated 4 October 2022, 12:10 am EST

    Hello,

    Thank you for your respond!

    But when set IsSelected = “False”, the Textbox can not be edited in the next column, This is not what I want and I need set IsEnable = “False” in Cellstyle,not set in Textblock and textbox.

    I saw in .dll DatagridCellPresenter you set VisualState = “Disabled” when IsEnable = “False”. Do you understand and Can you help me?

    Thanks!

  • Posted 21 November 2018, 2:16 am EST

    Hello,

    Could you try to test the attached application and see it works for you?

    ~Ruchir

    WPFBlankApp2.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels