SettingsPane Focus

1 Answer 121 Views
Chart GridView Window
Valentin
Top achievements
Rank 1
Iron
Iron
Valentin asked on 22 Feb 2022, 09:59 AM

Hello,

I'm using a custom SettingsPane based on the one you developped (Telerik\UI for WPF R2 2017\Themes.Implicit\WPF40\Windows7\Themes). This pane is used to customize all of the shapes (basic RadShapes and custom shapes) in a RadDiagram.

In this pane, there is a tab (it content is a UserControl) which allows the user to add values (from a RadGridView) to a serie in a RadChart (ScatterChart). The RadGridView allows the copy/paste functionnality to paste some values from Excel (for example).

However, I have a strange behavior about the focus: if I open the pane and the dedicated tab, I go to Excel to copy the data, click on the RadGridView before paste the data, then the main window and the pane don't take the focus. On the contrary, if I copy the data before opening the pane and the tab, there aren't any problems with the focus, the pasting is correctly done.

When the problem occurs, we can see that the main window header is light grey, to indicate that it doesn't have the focus.

Do you know something about this behavior? Do you have any solution? 

 

Many thanks.

Valentin.

Dilyan Traykov
Telerik team
commented on 24 Feb 2022, 10:04 AM

Hello Valentin,

I'm afraid I cannot pinpoint an exact cause and suggest a viable solution for this behavior without being able to replicate it at my end. Would you find it possible to isolate this in a small sample project so that I can further assist you?
Valentin
Top achievements
Rank 1
Iron
Iron
commented on 25 Feb 2022, 02:51 PM

Hi Dilyan,

Sadly, I can't give you a sample part of the code because the project is too big and there are some sensitive data...

Do you know if exist somethings to force a focus to a parent after click on the RadGridView or any composant as described?

Thank you.
Valentin.

Dilyan Traykov
Telerik team
commented on 01 Mar 2022, 11:39 AM

Hello Valentin,

I'm afraid I cannot suggest a viable solution without being able to test it at my end. You can, however, try the approach suggested in this thread: WPF-MVVM: Setting UI control focus from ViewModel.

If that does not work, I can suggest trying to reproduce this in a new isolated project. The sensitive data can be replaced with dummy data as this will most probably be irrelevant to the issue. The main goal would be to replicate the same setup and layout. Do let me know if you would find this possible.
Valentin
Top achievements
Rank 1
Iron
Iron
commented on 02 Mar 2022, 03:25 PM

Hi Dilyan,

You can find below a link to download a sample project allowing you to reproduce my issue.
https://we.tl/t-Y6VS7ajPGH -> The link is available only one week.

Steps to reproduce:
- Click on the shape
- Click on the settings button
- Click on the textbox
- Change window (to copy data from Excel/Gsheet for example)
- Click on the textbox again
- Try to paste clipboard or right something: the focus isn't on the main window/textbox but on the other window.

Thank you for your help.
Valentin.

Dilyan Traykov
Telerik team
commented on 07 Mar 2022, 11:20 AM

Hi Valentin,

Thank you very much for the provided sample project. I can confirm that I was able to replicate the issue, however, it seems to stem from the WPF framework rather than the implementation of the RadDiagram control. You can notice that the default settings pane closes when the parent window loses the focus and this is by design.

I was able to replicate the same issue using only native WPF controls and am attaching an updated version of your project which demonstrates this. You can notice that the focus cannot be brought to the TextBox unless the parent window is focused.

With this said, I can suggest forwarding your inquiry to the MSDN and/or StackOverflow forums to get further assistance on whether it would be possible to achieve the desired result.

I hope you find this information helpful.
Valentin
Top achievements
Rank 1
Iron
Iron
commented on 08 Mar 2022, 09:07 AM

Hi Dilyan,

Thank you for analysis and your feedback. I wrote a question on StackOverflow using your sample projet, I hope I'll have a solution!
https://stackoverflow.com/questions/71392416/why-mainwindow-doesnt-take-the-focus-from-a-popup-child

Many thanks,
Valentin

1 Answer, 1 is accepted

Sort by
0
Accepted
Valentin
Top achievements
Rank 1
Iron
Iron
answered on 09 Mar 2022, 04:13 PM

Hello,

Here a by-pass for this behavior: I added the PreviewMouseLeftButtonDown="MySettingPane_PreviewMouseLeftButtonDown" event to the SettingsPane of my RadDiagram and call the following method:

        Private Sub MySettingPane_PreviewMouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
            Me.ParentOfType(Of Window).Activate()
        End Sub

This function force the focus to the MainWindow.

Thank you for your analysis!
Valentin.

Dilyan Traykov
Telerik team
commented on 11 Mar 2022, 01:34 PM

Hello Valentin,

Thank you very much for sharing your solution with our community!
Tags
Chart GridView Window
Asked by
Valentin
Top achievements
Rank 1
Iron
Iron
Answers by
Valentin
Top achievements
Rank 1
Iron
Iron
Share this question
or