WPF-MVVM: Setting UI control focus from ViewModel

后端 未结 5 992
旧时难觅i
旧时难觅i 2020-12-08 09:14

What is a good practice of setting control focus in MVVM architecture.

The way I envision it, is with a property on the ViewModel that would trigger a focus change

5条回答
  •  执念已碎
    2020-12-08 10:07

    Use the IsFocused Attached Property as suggested in the Answer here: Set focus on textbox in WPF from view model (C#)

    Then you can simply bind to a property in your viewmodel.

提交回复
热议问题