How to Focus an TextBox on Button click

前端 未结 3 835
猫巷女王i
猫巷女王i 2021-01-14 04:55

So how to Focus an TextBox on Button click using the MVVM Pattern?

i created an simple Testproject Based on this Answer which works on the first click, but after tha

3条回答
  •  旧时难觅i
    2021-01-14 05:45

    You should make a command for lostFocus event, and when focus is lost, set isFocused property to false, then it will be working. Add Interactivity and Interactions librarys into your project, than you will be able to write something like :

     
        
            
        
     
    

    and in your viewModel write:

    public void OnLostFocus()
    {IsFocused = false;}
    

    and move RaisePropertyChanged to the setter of your property

提交回复
热议问题