Multiple InfoBarMessageControls and Model vs. ViewModel validation

Topics: Questions
Aug 9, 2012 at 11:22 AM

I have put my own InfoBarMessageControl in one of my controls as I want to display the errors further down and not on top of the window (it contains a ribbon which makes it look a bit weird with the error bar on top of it).

 

<catel:InfoBarMessageControl DockPanel.Dock="Top" Mode="Overlay">
       <catel:WarningAndErrorValidator Source="{Binding Item}" 
Visibility
="Visible" /> </catel:InfoBarMessageControl>

At first, it did show the errors when the Item (DataObjectBase) failed validation but the red border was not present. I then added those two attributes to the binding:

<TextBox Text="{Binding Item.CompanyNumber, 
UpdateSourceTrigger=PropertyChanged,
ValidatesOnDataErrors=True, NotifyOnValidationError=True}
" />

Now the red border is there, but I have two InfoBarMessageControls. One from me and the default from Catel.

Can I disable the default control?

Also, when validating the above used Item property (Model-property that is)

#region PROPERTY Item
[Model]
public T Item
{
    get { return GetValue<T>(ItemProperty); }
    set
    {
        SetValue(ItemProperty, value);
        IsDirty = false;
    }
}

public static readonly PropertyData ItemProperty = RegisterProperty("Item", typeof(T));
#endregion

and a bind the WarningAndErrorValidation to the viewmodel instead of the model no validations are shown. I was hoping (and I though I read this somewhere), that when invalidating the model, the viewmodel would also be invalidated. But checking the appropriate IsError properties, I find this not to be so.

For info, I do not use the ViewModelToModel concept but access the Model through e.g, Item.CompanyNumber.

thanks for any insights and ideas,

G.

 

 

Coordinator
Aug 9, 2012 at 11:35 AM

In the DataWindow, the last constructor argument is the InfoBarMessageGeneration or something like that. You can choose none.

Aug 9, 2012 at 12:33 PM

Hmm, if I set it to None, the UI hangs as soon as my user control gets displayed(?) or so. Weird, I removed all validation logic, the special catel validation controls, but it still hangs. But only if the constructor passes None.

Coordinator
Aug 9, 2012 at 12:35 PM

Very interesting, can you send us a small repro?

Aug 9, 2012 at 12:35 PM

What I find weird is the following stracktrace of the main thread when I hit break:

>    Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalAncestor(System.Windows.DependencyObject startElement = {Cytec.Lims.FrontEnd.SampleShipment.View.MainWindow}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = 1) + 0x6b bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {Cytec.Lims.FrontEnd.SampleShipment.View.MainWindow}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0x46 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Documents.AdornerDecorator}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.ContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Bars.BarManager}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.DockLayoutManager}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.psvDockPanel}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.ContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.LayoutGroup}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.MultiTemplateControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.GroupPane}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.DropBoundsControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.psvContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.GroupPaneContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.BaseGroupContentControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.LayoutItemsControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.ItemsPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.GroupPanel}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.DocumentGroup}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.MultiTemplateControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.DocumentPane}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.DocumentPaneContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.DocumentTabContainer}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.DockingSplitLayoutPanel}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.DockDependentDecorator}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.LayoutTabFastRenderPanel}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.ContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.DocumentPanel}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.MultiTemplateControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.Document}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.DocumentContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Docking.VisualElements.psvContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.ContentControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {Cytec.Lims.Framework.WPF.View.DetailWithLoadControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Border}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.ContentPresenter}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.Grid}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {DevExpress.Xpf.Bars.BarManager}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xe9 bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.DockPanel}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.DependencyObjectExtensions.FindLogicalOrVisualAncestor(System.Windows.DependencyObject startElement = {System.Windows.Controls.ContentControl}, System.Predicate<object> condition = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0xad bytes   
     Catel.MVVM.dll!Catel.Windows.Controls.MVVMProviders.Logic.UserControlLogic.FindParentByPredicate(System.Windows.Controls.UserControl control = {Cytec.Lims.FrontEnd.MasterData.View.CompanyDetailControl}, System.Predicate<object> predicate = {Method = {System.Reflection.RuntimeMethodInfo}}, int maxDepth = -1) + 0x122 bytes   
     Catel.MVVM.dll!Catel.Windows.Controls.MVVMProviders.Logic.UserControlLogic.FindParentByPredicate(System.Windows.Controls.UserControl control = {Cytec.Lims.FrontEnd.MasterData.View.CompanyDetailControl}, System.Predicate<object> predicate = {Method = {System.Reflection.RuntimeMethodInfo}}) + 0x28 bytes   
     Catel.MVVM.dll!Catel.Windows.Controls.MVVMProviders.Logic.UserControlLogic.OnTargetControlLoaded(object sender = {Cytec.Lims.FrontEnd.MasterData.View.CompanyDetailControl}, System.EventArgs e = {System.Windows.RoutedEventArgs}) + 0xe1 bytes   
     Catel.MVVM.dll!Catel.Windows.Controls.MVVMProviders.Logic.LogicBase.OnTargetControlLoadedInternal(object sender = {Cytec.Lims.FrontEnd.MasterData.View.CompanyDetailControl}, System.EventArgs e = {System.Windows.RoutedEventArgs}) + 0x152 bytes   
     PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x7a bytes   
     PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {Cytec.Lims.FrontEnd.MasterData.View.CompanyDetailControl}, System.Windows.RoutedEventArgs args = {System.Windows.RoutedEventArgs}, bool reRaised = false) + 0x1ae bytes   
     PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {Cytec.Lims.FrontEnd.MasterData.View.CompanyDetailControl}, System.Windows.RoutedEventArgs args = {System.Windows.RoutedEventArgs}) + 0x79 bytes   
     PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs e) + 0x29 bytes   
     PresentationFramework.dll!System.Windows.BroadcastEventHelper.BroadcastEvent(System.Windows.DependencyObject root, System.Windows.RoutedEvent routedEvent = {System.Windows.RoutedEvent}) + 0x135 bytes   
     PresentationFramework.dll!System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(object root) + 0xa9 bytes   
     PresentationCore.dll!MS.Internal.LoadedOrUnloadedOperation.DoWork() + 0x16 bytes   
     PresentationCore.dll!System.Windows.Media.MediaContext.FireLoadedPendingCallbacks() + 0x35 bytes   
     PresentationCore.dll!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() + 0x2e bytes   
     PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandlerCore(object resizedCompositionTarget = null) + 0x8a bytes   
     PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandler(object resizedCompositionTarget) + 0x2c bytes   
     WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x53 bytes   
     WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source = {System.Windows.Threading.Dispatcher}, System.Delegate method, object args, int numArgs, System.Delegate catchHandler = null) + 0x42 bytes   
     WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() + 0x8d bytes   
     WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) + 0x38 bytes   
     mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x51 bytes   
     [Native to Managed Transition]   
     [Managed to Native Transition]   
     mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6a bytes   
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0x7e bytes   
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes   
     WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0x68 bytes   
     WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() + 0x15e bytes   
     WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x63 bytes   
     WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd = 3215968, int msg = 49421, System.IntPtr wParam = 0, System.IntPtr lParam = 0, ref bool handled = false) + 0xbe bytes   
     WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x7d bytes   
     WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x53 bytes   
     WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source = {System.Windows.Threading.Dispatcher}, System.Delegate method, object args, int numArgs, System.Delegate catchHandler = null) + 0x42 bytes   
     WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) + 0xb4 bytes   
     WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd = 3215968, int msg = 49421, System.IntPtr wParam = 0, System.IntPtr lParam = 0) + 0x104 bytes   
     [Native to Managed Transition]   
     [Managed to Native Transition]   
     WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame = {System.Windows.Threading.DispatcherFrame}) + 0xc1 bytes   
     WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) + 0x49 bytes   
     WindowsBase.dll!System.Windows.Threading.Dispatcher.Run() + 0x4c bytes   
     PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) + 0x17 bytes   
     PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) + 0x6f bytes   
     PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) + 0x26 bytes   
     PresentationFramework.dll!System.Windows.Application.Run() + 0x1b bytes   
     Cytec.Lims.FrontEnd.SampleShipment.exe!Cytec.Lims.FrontEnd.SampleShipment.App.Main() + 0x5e bytes    C#
     [Native to Managed Transition]   
     [Managed to Native Transition]   
     mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x6d bytes   
     Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2a bytes   
     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes   
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes   
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes   
     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes   
     [Native to Managed Transition]   

 

Is this normal to have so many FindLogicalOrVisualAncestor calls?

Coordinator
Aug 9, 2012 at 12:36 PM

Hmmm, you might want to enable "SkipSearchingForInfoBarMessageControl".

Aug 9, 2012 at 12:47 PM

UserControlBehavior.DefaultSkipSearchingForInfoBarMessageControlValue = true; 
did the trick. Funny though, I would have thought that my own InfoBarMessageControl would then also be not found, but it is. It no works now as desired.

Another small issue/quesion. WPF does use the red border out of the box when e.g. a number textbox is empty. But then (of course) there is no Catel error message in the InfoBarMessageControl. Can this be accomplished?

Thanks

Coordinator
Aug 9, 2012 at 12:50 PM

You have to define custom styles for that. Catel shows this out of the box if I remember correctly if you link the default styles of Catel and use the style forwarder.

See this theme for an example.

Aug 9, 2012 at 1:28 PM

I still try to incorporate errors from the model (Item) and from the view model. Both have an overridden ValidateFields method. On either error the appropriate control is red bordered. But I cannot get the InfoBarMessageControl to show both errors. I tried:

            <catel:InfoBarMessageControl DockPanel.Dock="Top" Mode="Overlay">
                <StackPanel Orientation="Vertical">
                    <catel:WarningAndErrorValidator Source="{Binding Item}" Visibility ="Visible" />
                    <catel:WarningAndErrorValidator Source="{Binding}" Visibility ="Visible" />
                </StackPanel>
            </catel:InfoBarMessageControl>

But to no avail. Is there another way?

(and why are the errors from the model not propageted to the viewmodel in the first place)

Coordinator
Aug 9, 2012 at 2:42 PM

If the errors are exposed by the models, but not by your view model, you will need to add a custom WarningAndErrorValidator for all of your models. If you use ViewModelToModel mappings, the errors are propagated to the view model and displayed.

Do the models support IDataErrorInfo or INotifyDataErrorInfo? Those are the only ways the WarningAndErrorValidator can keep an eye on the errors. If you use DataObjectBase for your models, it is supported out of the box.

Aug 9, 2012 at 2:46 PM

But how to add more than one WarningAndErrorValidator? Using the StackPanel does not. Using any one of them shows the appropriate errors, but if two are specified, only the first is displayed.

The model is from DataObjectBase inherited.

Coordinator
Aug 9, 2012 at 2:50 PM

You can add as many as you want, they all subscribe to the InfoBarMessageControl if I remember correctly.

Aug 9, 2012 at 3:41 PM

As InfoBarMessageControl is a content control it can only have a singe child. How to add multiple WarningAndErrorValidators then? Using the Stack panel does not work.

Coordinator
Aug 11, 2012 at 10:47 AM

Strange. What Catel internally does when you use automatic mode is create an InfoBarMessageControl with 1 child (a grid). This contains the rest of the content. Strange that a stackpanel is not working.

Can you provide a repro so I can fix it?