how to recover wpf dialogcontent focus?

Viewed 91

I am developing add-in to outlook (VSTO, user taskpane).

Inside it I am using wpf with material design (http://materialdesigninxaml.net/). I have an issue with dialoghost from that library, when I switch focus to another app or part of MS Outlook it is almost impossible to get focus within that dialoghost.dialogcontent control back. Buttons work, but it is impossible to write anything in textboxes. Clicking on those controls, textboxes etc. is not working, keyboard focus is still somewhere else.

I've tried to use:

this.focus
Keyboard.focus
FocusManager.SetFocusedElement

in event handlers (control_PreviewKeyDown or control_MouseEnter) but not working.

<materialDesign:DialogHost.DialogContent>
<ContentControl x:Name="DialogContentControl"
ContentTemplateSelector="{StaticResource  DTSDialogObject}"
Focusable="True"
Content="{Binding DialogViewModel,
UpdateSourceTrigger=PropertyChanged,
Mode=OneWay}"
HorizontalAlignment="Center"
Width="300"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center" />
</materialDesign:DialogHost.DialogContent>

I am able to select text in textbox, but even then keyboard input is still set somewhere else...

Order:

  1. I am writing something in textbox (that is a child control of dialogcontentcontrol)
  2. I move focus somewhere else (Visual Studio, Notepad, Outlook mail, whatever)
  3. Click again on that textbox
  4. Select text with mouse
  5. Typing on keyboard = typing somewhere else (point 2), not in the textbox

Any ideas?

0 Answers
Related