You can try something like this to set the selection in the PasswordBox:
private void SetSelection(PasswordBox passwordBox, int start, int length) {
passwordBox.GetType().GetMethod("Select", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(passwordBox, new object[] { start, length });
}
After that, call it like this to set the cursor position:
// set the cursor position to 2...
SetSelection( passwordBox1, 2, 0);
// focus the control to update the selection
passwordBox1.Focus();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…