我创建了一个绑定到实现IDataErrorInfo的实体的wpf文本框。当文本框无效时(由于它没有通过IDataErrorInfo验证而在其周围显示红色框)并且文本框的IsEnabled属性设置为false,我可以多次单击文本框并删除文本框内的文本(字符串) .Empty传递给实体)。
这里发生了什么?这是预期的行为吗?
编辑:我删除了isEnabled并添加了isreadonly和focusable。我意识到如果我没有点击文本框,它会在验证失败时删除。
编辑:然后,我删除了焦点并再次尝试。这一次,直到我点击表示验证的红线上的任何内容都没有删除。
编辑:我的文本框位于DataGridTemplateColumn内DataGridTemplateColumn.CellTemplate内部的DataTemplate内。
callstack如下:
MyCode.DLL!MyCode.Models.Entity.PropertyName.set(string value)第66行C# [原产于管理过渡]
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.SetValue(对象项,对象值)未知 PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.UpdateValue(对象值)未知 PresentationFramework.dll!System.Windows.Data.BindingExpression.UpdateSource(object value)Unknown PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.UpdateValue()未知 PresentationFramework.dll!System.Windows.Data.BindingExpression.UpdateOverride()未知 PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.Update()未知 PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.ProcessDirty()未知 PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.Dirty()未知 PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.SetValue(System.Windows.DependencyObject d,System.Windows.DependencyProperty dp,object value)Unknown WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp,object value,System.Windows.PropertyMetadata metadata,bool coerceWithDeferredReference,bool coerceWithCurrentValue,System.Windows.OperationType operationType,bool isInternal)Unknown WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp,object value)Unknown PresentationFramework.dll!System.Windows.Data.BindingExpression.GetInitialValue(System.Windows.DependencyObject target,out System.Windows.Controls.ValidationError error)Unknown PresentationFramework.dll!System.Windows.Data.BindingExpression.Activate(object item)Unknown PresentationFramework.dll!System.Windows.Data.BindingExpression.AttachToContext(System.Windows.Data.BindingExpression.AttachAttempt attempt)Unknown PresentationFramework.dll!System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(bool lastChance)Unknown PresentationFramework.dll!MS.Internal.Data.DataBindEngine.Task.Run(bool lastChance)未知 PresentationFramework.dll!MS.Internal.Data.DataBindEngine.Run(object arg)未知 PresentationFramework.dll!MS.Internal.Data.DataBindEngine.OnLayoutUpdated(object sender,System.EventArgs e)未知 PresentationCore.dll!System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()未知 PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayout()未知 PresentationCore.dll!System.Windows.UIElement.UpdateLayout()未知 PresentationFramework.dll!System.Windows.Controls.DataGridCell.BeginEdit(System.Windows.RoutedEventArgs e)未知 PresentationFramework.dll!System.Windows.Controls.DataGrid.OnExecutedBeginEdit(System.Windows.Input.ExecutedRoutedEventArgs e)未知 PresentationFramework.dll!System.Windows.Controls.DataGrid.OnExecutedBeginEdit(object sender,System.Windows.Input.ExecutedRoutedEventArgs e)Unknown PresentationCore.dll!System.Windows.Input.CommandBinding.OnExecuted(object sender,System.Windows.Input.ExecutedRoutedEventArgs e)Unknown PresentationCore.dll!System.Windows.Input.CommandManager.ExecuteCommandBinding(object sender,System.Windows.Input.ExecutedRoutedEventArgs e,System.Windows.Input.CommandBinding commandBinding)Unknown PresentationCore.dll!System.Windows.Input.CommandManager.FindCommandBinding(object sender,System.Windows.RoutedEventArgs e,System.Windows.Input.ICommand command,bool execute)Unknown PresentationCore.dll!System.Windows.Input.CommandManager.OnExecuted(object sender,System.Windows.Input.ExecutedRoutedEventArgs e)Unknown PresentationCore.dll!System.Windows.UIElement.OnExecutedThunk(object sender,System.Windows.Input.ExecutedRoutedEventArgs e)Unknown PresentationCore.dll!System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(System.Delegate genericHandler,object target)Unknown PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler,object target)Unknown PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,System.Windows.RoutedEventArgs routedEventArgs)未知 PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(对象源,System.Windows.RoutedEventArgs args,bool reRaised)未知 PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender,System.Windows.RoutedEventArgs args)Unknown PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args,bool trusted)Unknown PresentationCore.dll!System.Windows.Input.RoutedCommand.ExecuteImpl(object parameter,System.Windows.IInputElement target,bool userInitiated)Unknown PresentationCore.dll!System.Windows.Input.RoutedCommand.Execute(object parameter,System.Windows.IInputElement target)Unknown PresentationFramework.dll!System.Windows.Controls.DataGrid.BeginEdit(System.Windows.RoutedEventArgs editingEventArgs)Unknown PresentationFramework.dll!System.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)Unknown PresentationFramework.dll!System.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDownThunk(object sender,System.Windows.Input.MouseButtonEventArgs e)Unknown PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler,object genericTarget)Unknown PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler,object target)Unknown PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,System.Windows.RoutedEventArgs routedEventArgs)未知 PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(对象源,System.Windows.RoutedEventArgs args,bool reRaised)未知 PresentationCore.dll!System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject sender,System.Windows.RoutedEventArgs args,System.Windows.RoutedEvent newEvent)Unknown PresentationCore.dll!System.Windows.UIElement.OnMouseDownThunk(object sender,System.Windows.Input.MouseButtonEventArgs e)Unknown PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler,object genericTarget)Unknown PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler,object target)Unknown PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,System.Windows.RoutedEventArgs routedEventArgs)未知 PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(对象源,System.Windows.RoutedEventArgs args,bool reRaised)未知 PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender,System.Windows.RoutedEventArgs args)Unknown PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs args)Unknown PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args,bool trusted)Unknown PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea()未知 PresentationCore.dll!System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs input)Unknown PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport inputReport)Unknown PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(System.IntPtr hwnd,System.Windows.Input.InputMode mode,int timestamp,System.Windows.Input.RawMouseActions actions,int x,int y,int wheel)Unknown PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage(System.IntPtr hwnd,MS.Internal.Interop.WindowMessage msg,System.IntPtr wParam,System.IntPtr lParam,ref bool handling)Unknown PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd,int msg,System.IntPtr wParam,System.IntPtr lParam,ref bool handling)Unknown WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd,int msg,System.IntPtr wParam,System.IntPtr lParam,ref bool handling)Unknown WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o)未知 WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback,object args,int numArgs)Unknown WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,System.Delegate回调,对象args,int numArgs,System.Delegate catchHandler)未知 WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority,System.TimeSpan timeout,System.Delegate method,object args,int numArgs)Unknown WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd,int msg,System.IntPtr wParam,System.IntPtr lParam)未知 [AppDomain Transition]
答案 0 :(得分:0)
我从未弄明白为什么,但我发现使用private int count = 1;
Runnable runnable = null;
private void showProgressDialog() {
progressDialog = new ProgressDialog(this, getProgressDailogStyle());
progressDialog.setMessage("Processing ...");
progressDialog.show();
progressDialog.setCancelable(false);
final Handler handler = new Handler();
runnable = new Runnable() {
public void run() {
Log.i("message",""+counter);
if (counter == 5) {
handler.removeCallbacks(runnable);
progressDialog.dismiss();
// mInterstitialAd.show();
}else {
progressDialog.setMessage("your message");
handler.postDelayed(runnable, 2000);
counter++;
}
}
};
handler.post(runnable);
}
和CellTemplate
解决了我的问题。
对于那些关注我的帖子然后逃跑的人,如果你不能理解复杂性,我建议你在将来忽略这个问题。