問題タブ [passwordbox]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
wpf - AttachProperty を使用した PasswordBox の ErrorTemplate
wpf の passwordbox が Validation.ErrorTemplate を使用できないことはわかっていますが、とにかく何かが間違っていることをユーザーに示す必要があります。
私のパスワードボックスには、このようなバインディングがあります
何か問題がある場合、このパスワードボックスのデフォルトのエラー テンプレート (赤い境界線) のような同じスタイルを取得することは可能ですか?
これは、他のコントロールに使用する ErrorTemplate です
ありがとう
windows-phone-7 - WP7 のパスワードボックスでパスワードを中央揃えにできません
Windows Phone の PasswordBox でパスワードを中央揃えにできません。中央揃えは無効です。テキストを中央に揃える方法はありますか?
verticalcontentalignment と horizontalcontentalignment を中央に設定しようとしましたが、効果がありません。または、パスワード ボックスの境界線とパスワードの間にスペースを空けることは可能ですか。
アルファ
.net - PasswordBoxコントロールがWPFアプリケーションをクラッシュさせるのはなぜですか?
PasswordBox
私は、なぜそれが私に多くの問題を引き起こしているのかを理解しようと良い一日を過ごしました。
テストしたすべてのマシンで動作するアプリケーションがあります。これで他のマシンにインストールされ、内部をクリックするたびにクラッシュしますPasswordBox
。とコントロール
だけを使用してテストアプリケーションを作成し、アプリケーションの基になるコードがクラッシュの原因であるかどうかを確認しましたが、そうではないことがわかりました。をクリックすると、正常に動作します。その中にテキストを入力できます。しかし、をクリックするとすぐに、アプリケーションがクラッシュします。 TextBox
PasswordBox
TextBox
PasswordBox
未処理の例外をキャッチするために、これらのイベントを設定しました。
Application.Current.DispatcherUnhandledException
AppDomain.CurrentDomain.UnhandledException
AppDomain.CurrentDomain.FirstChanceException
これでMessageBox
、エラーが発生した場合にが表示されます。最悪の部分は、これらのイベントにスローされたエラーがないことです。
アプリケーションにいくつかのロギングを設定しましたが、次のような例外が発生しました。
- オブジェクト参照がオブジェクトのインスタンスに設定されていません
- 保護されたメモリの読み取りまたは書き込みを試みました。これは多くの場合、他のメモリが破損していることを示しています。
クラッシュする前にフォーカスが取得されたかどうかをテストするためのイベントを設定していたので、オブジェクト参照の例外がコントロールPasswordBox
を参照しているとは思いません。
私はどこでも検索して、他の誰かがこれらの問題を抱えていて、.NET4.0で修正されるはずのコントロールとそのフォーカスの問題 だけを見たことがありますか?PasswordBox
TextBox
おー!そしてそれは私に思い出させます。WPF.NET4.0を使用しています。
どんな助けでも大歓迎です。
テストコードは次のとおりです。
そしてXaml:
イベントビューアー
マシンのイベントビューアからの例外は次のとおりです。
アプリケーション:WPF Control Test.exe
フレームワークバージョン:v4.0.30319
説明:アプリケーションは、System.Environment.FailFast(文字列メッセージ)を介してプロセスの終了を要求しました。
メッセージ:回復不能なシステムエラー。
スタック:
System.Environment.FailFast(System.String)
at MS.Internal.Invariant.FailFast(System.String、System.String)
at System.Windows.Media.FontFamily.get_FirstFontFamily()
at System.Windows.Documents.TextSelection
System.Windows.Documents.TextSelection.UpdateCaretStateWorker(System.Object)の.CalculateCaretRectangle(System.Windows.Documents.ITextSelection、System.Windows.Documents.ITextPointer )
System.Windows.Documents.TextSelection.UpdateCaretState(System.Windows.Documents.CaretScrollMethod)
at System.Windows.Documents.TextSelection.EnsureCaret(Boolean、System.Windows.Documents.CaretScrollMethod)
at System.Windows.Documents.TextSelection.System .Windows.Documents.ITextSelection.UpdateCaretAndHighlight()
at System.Windows.Documents.TextEditor.OnGotKeyboardFocus(System.Object、System.Windows.Input.KeyboardFocusChangedEventArgs)
at System.Windows.Controls.PasswordBox.OnGotKeyboardFocus(System.Windows.Input。
System.Windows.UIElement.OnGotKeyboardFocusThunk(System.Object、System.Windows.Input.KeyboardFocusChangedEventArgs)のKeyboardFocusChangedEventArgs)
System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(System.Delegate、System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate、System.Object)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object、System .Windows.RoutedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object、System.Windows.RoutedEventArgs、Boolean)
at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject、System.Windows.RoutedEventArgs) atSystem
。 Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs、Boolean)
at System.Windows.Input.InputManager.ProcessStagingArea()
System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
at System.Windows.Input.KeyboardDevice.ChangeFocus(System.Windows.DependencyObject、Int32)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(System .Windows.DependencyObject、System.Windows.Input.IKeyboardInputProvider、Boolean、Boolean、Boolean)
at System.Windows.Input.KeyboardDevice.Focus(System.Windows.DependencyObject、Boolean、Boolean、Boolean)
at System.Windows.Input.KeyboardDevice .Focus(System.Windows.IInputElement)
at System.Windows.UIElement.Focus()
at System.Windows.Documents.TextEditorMouse.MoveFocusToUiScope(System.Windows.Documents.TextEditor)
System.Windows.Documents.TextEditorMouse.OnMouseDown(System.Object、System.Windows.Input.MouseButtonEventArgs)
at System.Windows.Controls.PasswordBox.OnMouseDown(System.Windows.Input.MouseButtonEventArgs)
at System.Windows.UIElement.OnMouseDownThunk (System.Object、System.Windows.Input.MouseButtonEventArgs)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate、System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate、System.Object)
at System.Windows.EventHandlerInfo.InvokeHandler(System.Object、System.Windows.RoutedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object、System.Windows.RoutedEventArgs、Boolean)
System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject、System.Windows.RoutedEventArgs)
at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs 、ブール値)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input .InputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr、System.Windows.Input.InputMode、Int32、System.Windows.Input.RawMouseActions、Int32、Int32、Int32)
System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr、MS.Internal.Interop.WindowMessage、IntPtr、IntPtr、Boolean ByRef)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef)
MS.Win32.HwndWrapper.WndProc(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate、System。 Object、Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object、System.Delegate、System.Object、Int32、System.Delegate)
System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority、System.TimeSpan、System.Delegate、System.Object、Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr、Int32、IntPtr、IntPtr)
MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(System。 Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run(System.Windows.Window)
System.Windows.Application.Run()
のWPF_Control_Test.App.Main()
wpf - WPF PasswordBox でのエラー処理
Josh Smith のサンプル アプリケーションの作成方法には、いつも感心しています。また、彼のアプリケーションの ViewModels が IDataErrorInfo プロパティを実装し、カスタム DataTemplate を介してユーザーの前にエラーをレンダリングする方法をエミュレートしようとしました。エラーを表示するために彼が使用するデータ テンプレートは次のとおりです。
このデータ テンプレートが使用される作業サンプルは次のとおりです。
テキスト ボックスのデフォルトの ErrorTemplate (周囲に表示される赤い境界線) は、テキスト ボックスのすぐ下に配置されたコンテンツ プレゼンターがユーザーにエラーを伝える新しいエラー テンプレートに置き換えられます。これは確かに優れた、より洗練されたテンプレートです。
上記のコードを読んだことがあれば、ログイン フォームを作成しようとしていることがわかるでしょう。
残念ながら、ログイン フォームはパスワード (およびそれに続く PasswordBox) を要求します。PasswordBox は依存プロパティとして "Password" を提供しません。コードビハインドをできるだけ回避しようとするMVVMガイドラインを破りたくなかったので、ここで言及されているPasswordBoxAssistantクラスに行きたくなりました. そうでなければ、これは良い解決策です.1つだけ保存してください。Josh のデータ テンプレートを使用してパスワード ボックスを検証できません。ViewModel のパスワード プロパティが空でないことを確認しました。ユーザーがパスワードを入力しないと「ログイン」ボタンが有効にならないため、プロパティは検証されています。しかし、このプロパティ検証の一部として設定した「パスワードを入力してください」というメッセージは、PasswordBox の下にあるコンテンツ プレゼンターによってレンダリングされません。コードは次のとおりです。
言うまでもなく、上記のコードの ff は名前空間参照を表しています。
Password プロパティがヘルパー クラスによって拡張されているため、この問題が発生していると確信しています。このアプローチをやめると、Password プロパティを IDataErrorInfo 実装から削除する必要があり、[ログイン] ボタンのクリック時にそれを確認して、ユーザーにメッセージ ボックスを表示する必要があります。しかし、一貫性を損なうことなくではありません。依存関係プロパティについてはあまり知りません。回避策はありますか?何らかの方法でヘルパー クラスを変更すると、赤いエラー メッセージが表示されるようになりますか?
wpf - WPFでのカスタムコントロール:数値PasswordBoxの作成
次のようにTextBoxを継承して、数値のTextBoxを作成しました。
しかし、パスワードボックスは封印されたクラスであるため、PasswordBoxに対して同じことを行うことはできません。PasswordBoxでこれをどのように達成できますか?
winforms - Windows Forms.NET でシステム パスワード char を使用してテキストをパスワードとしてレンダリングする
Windows フォームTextBox
コントロールには と の 2 つのプロパティがPasswordChar
ありUseSystemPasswordChar
、 に入力されたパスワードの隠蔽を制御しますTextBox
。指定されたテキストを非 TextBox グラフィックス サーフェスに同じ方法でレンダリングする必要があります。
PasswordChar プロパティの char を使用すれば、指定された文字列の長さを計算し、同等のテキスト表現を作成できますが、UseSystemPasswordChar はどうでしょうか? 有効なシステム パスワード char を取得するにはどうすればよいですか?
あるいは、このすべての作業を手動で行うことなく、指定されたテキストをパスワードとしてレンダリングするために使用できるフラグまたはすぐに使用できる .NET メソッドまたはクラスがあるのでしょうか?
c# - wpfのPasswordBboxでカーソル位置を見つける方法は?
上の図では、PasswordBox内の3つのテキスト値の後にカーソルが点滅しています。次に、カーソルが現在点滅している場所を見つけます。
c# - PasswordBox を TextBox として使用するには?
があり、PasswordBox
このコントロールをとしてもTextBox
使用する必要があります。典型的な黒い点ではなく、通常のテキストを表示する必要があります
これを行うプロパティはありますか?ありがとう。
windows-phone-7 - ヒントテキスト付きのパスワードボックス
Windows Phoneでヒントテキスト付きのパスワードボックスを表示するにはどうすればよいですか?
PasswordBox
とを試しましたToolkit's PhoneTextBox
。この2つを組み合わせるために特別なことはありますか?