c# - WPF MVVM Focus Field on Load -


I have a view that includes a single textbox and a pair button < / Code> This is below when the window is loaded so I want to TextBox for focus

If I was not using MVVM then I would just click the TextBox Focus () will call in the loaded event. Although my Voododel does not know about my thoughts, so how can I accomplish this without putting code into my idea code?

Edit: After reading the answer, I can see the xaml

  & lt; DocPanel Focus Manager FocusAlement = "{binding element name = message text box}" & gt; & Lt; Text box name = "message textbox" text = "{binding message}" /> & Lt; / DockPanel & gt;  

If this was anything other than the initial page focus, then I might suggest Johns Galloway's answer as it can be controlled with ViewModel.

If this makes you feel better (this makes me feel better) You can do this in XML using:

If you can do anything in code, you can do it in Xaml. If you know the tricks, you can do this trick. Did not apply - MS did this for you.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -