wpf passwordbox控件 光标移到最后

 1 /// <summary>
 2 /// 设置光标位置
 3 /// </summary>
 4 /// <param name="passwordBox"></param>
 5 /// <param name="start">光标开始位置</param>
 6 /// <param name="length">选中长度</param>
 7 private void SetSelection(PasswordBox passwordBox, int start, int length)
 8 { 
 9     passwordBox.GetType()
10                .GetMethod("Select", BindingFlags.Instance | BindingFlags.NonPublic)
11                .Invoke(passwordBox, new object[] { start, length }); 
12 } 

以上方法中 start传光标位置,length传0,即可控制

posted @ 2018-05-24 11:08  dyfisgod  阅读(1144)  评论(1编辑  收藏  举报