MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit
Refocus after Dialog close triggers Tab change
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 16.3k
- Fork
- 3.5k
- Merge medio
- 1g 22h
- PR unite (30g)
- 8
Descrizione
The DialogHost tries to "re-focus" the item previously selected. This is the code for it:
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/5533b50a6cff78cb75fbb52e16f7c9e06c62446c/MaterialDesignThemes.Wpf/DialogHost.cs#L268
This is very problematic, when the previous control was a TabItem, because Focus()ing a TabItem actually activates the respective tab.
Here is a very simple reproduction:
- Have a TabControl within a DialogHost
- Focus a given TabItem (i.e. by clicking on an already active Tab)
- In the SelectionChanging Event of the TabControl Show the Dialog (i.e. "Loading data ...")
- Click another Tab
The following happens:
- DialogHost remembers, that the first tab is currently focused
- The click on the second Tab activates this Tab
- Dialog is shown and closed again, after data is loaded
- Dialog calls Focus() on first tab
=> First tab will be selected again
I just created the issue as I'm not sure, what the best solution for this. My current feeling tells me to just check for if(!(dialogHost._restoreFocusDialogClose is TabItem), but there might be other elements, where a re-focus is not desired?
I'd be happy to provide a PR after we agree on a solution.
Also - for now, I'd welcome any idea for a good workaround I could place into the application to make it work for now.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da DialogHost.cs intorno alla riga 268 e riproduci l’interazione con un TabControl, un TabItem e un gestore SelectionChanging che apre una finestra di dialogo. Verifica se il ripristino dello stato attivo sull’elemento selezionato in precedenza debba essere ignorato o gestito diversamente per gli elementi della scheda, e verifica che la chiusura della finestra di dialogo lasci attiva la scheda appena selezionata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- desktop
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100