In my UWP app I am trying to do custom validation. There are several TextBox
es inside a ContentDialog
and the primary button of this ContentDialog
acts as the submit button of this form (group of many text boxes). If there if something wrong, then I put focus on that control.
For example, if I have a TextBox Name="FirstName"
and the value inside this element fails validation, I do this.
FirstName.Text = string.Empty;
FirstName.Focus(FocusState.Programmatic);
When doing this in a mobile it scrolls up to the FirstName
TextBlock if it is not in view ( because the touch keyboard opens up with focus inside TextBlock
)
But in a desktop, doing
FirstName.Focus(FocusState.Programmatic);
does put the focus on the TextBlock but there is no scrolling up ( If it is not in view ). So I tried using this line of code :
FirstName.StartBringIntoView();
BUT THIS DOESN'T SEEM TO WORK.
However, I made it work using this answer , I was wondering what is the purpose of BringIntoView
or if I am using it wrong.