Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8788525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:10:04+00:00 2026-06-13T22:10:04+00:00

I use custom control in my WPF application. This custom control includes logic and

  • 0

I use custom control in my WPF application. This custom control includes logic and resource dictionary.
In my application I have login window and main window. Application first loads login window

<Application x:Class="Dest.App"
             ....
             StartupUri="Login.xaml">
</Application>

Custom control I use in my main window

<time:Calendar CloseAppointment="OnDeleteAppointment" AddAppointment="OnAddAppointment" Appointments="{Binding Path=Model}" />

Also in MainWindow I load resource dictionary from assembly

<ResourceDictionary>
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/WpfCalendar;component/Dictionary.xaml"/>
  </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

Visual Studio loads custom control without any exceptions. But when I load application and successfully login, viewmodel of the login view calls main windows

 MainWindow mainWindow = new MainWindow();
 mainWindow.Show();

Constructor of the main window

public MainWindow()
{
   InitializeComponent();    
   m_MainViewModel = new MainViewModel();
   this.DataContext = m_MainViewModel;
}

I receive an exception

Exception

Exception details

at WpfCalendar.Logic.Calendar.FilterAppointments() in
D:\development\Dental
Soft\LotusScheduler\WpfScheduler\WpfCalendar\Logic\Calendar.cs:line
122 at
WpfCalendar.Logic.Calendar.OnAppointmentsChanged(DependencyPropertyChangedEventArgs
e) in D:\development\Dental
Soft\LotusScheduler\WpfScheduler\WpfCalendar\Logic\Calendar.cs:line
109 at
WpfCalendar.Logic.Calendar.OnAppointmentsChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e) in D:\development\Dental
Soft\LotusScheduler\WpfScheduler\WpfCalendar\Logic\Calendar.cs:line
100 at
System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs
e) at
System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs
e) at
System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs
args) at
System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex
entryIndex, DependencyProperty dp, PropertyMetadata metadata,
EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean
coerceWithDeferredReference, Boolean coerceWithCurrentValue,
OperationType operationType) at
System.Windows.DependencyObject.InvalidateProperty(DependencyProperty
dp, Boolean preserveCurrentValue) at
System.Windows.Data.BindingExpressionBase.Invalidate(Boolean
isASubPropertyChange) at
System.Windows.Data.BindingExpression.TransferValue(Object newValue,
Boolean isASubPropertyChange) at
System.Windows.Data.BindingExpression.Activate(Object item) at
System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt
attempt) at
System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean
lastChance) at MS.Internal.Data.DataBindEngine.Task.Run(Boolean
lastChance) at MS.Internal.Data.DataBindEngine.Run(Object arg) at
MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender,
EventArgs e) at
System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() at
System.Windows.ContextLayoutManager.UpdateLayout() at
System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at
System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object
resizedCompositionTarget) at
System.Windows.Media.MediaContext.RenderMessageHandler(Object
resizedCompositionTarget) at
System.Windows.Media.MediaContext.Resize(ICompositionTarget
resizedCompositionTarget) at
System.Windows.Interop.HwndTarget.OnResize() at
System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg,
IntPtr wparam, IntPtr lparam) at
System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at
MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam,
IntPtr lParam, Boolean& handled) at
MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Int32 numArgs) at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object
source, Delegate method, Object args, Int32 numArgs, Delegate
catchHandler) at
System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Int32
numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32
msg, IntPtr wParam, IntPtr lParam) at
MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr
hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at
MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam) at
MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr
hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at
MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam) at
MS.Win32.UnsafeNativeMethods.SetWindowPos(HandleRef hWnd, HandleRef
hWndInsertAfter, Int32 x, Int32 y, Int32 cx, Int32 cy, Int32 flags) at
System.Windows.Window.SetupInitialState(Double requestedTop, Double
requestedLeft, Double requestedWidth, Double requestedHeight) at
System.Windows.Window.CreateSourceWindow(Boolean duringShow) at
System.Windows.Window.CreateSourceWindowDuringShow() at
System.Windows.Window.SafeCreateWindowDuringShow() at
System.Windows.Window.ShowHelper(Object booleanBox) at
System.Windows.Window.Show() at
ViewModel.LoginingViewModel.Login(Object parameter) in
D:\development\Dental
Soft\Lotus\AMS\Dentist\ViewModel\LoginingViewModel.cs:line 162 at
ViewModel.LoginingViewModel.b__0(Object param) in
D:\development\Dental
Soft\Lotus\AMS\Dentist\ViewModel\LoginingViewModel.cs:line 115 at
ViewModel.CommonCommand.Execute(Object parameter) in
D:\development\Dental
Soft\Lotus\AMS\Dentist\Commands\CommonCommand.cs:line 59 at
MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource
commandSource, Boolean userInitiated) at
System.Windows.Controls.Primitives.ButtonBase.OnClick() at
System.Windows.Controls.Button.OnClick() at
System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs
e) at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender,
MouseButtonEventArgs e) at
System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate
genericHandler, Object genericTarget) at
System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object
target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object
target, RoutedEventArgs routedEventArgs) at
System.Windows.EventRoute.InvokeHandlersImpl(Object source,
RoutedEventArgs args, Boolean reRaised) at
System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender,
RoutedEventArgs args, RoutedEvent newEvent) at
System.Windows.UIElement.OnMouseUpThunk(Object sender,
MouseButtonEventArgs e) at
System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate
genericHandler, Object genericTarget) at
System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object
target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object
target, RoutedEventArgs routedEventArgs) at
System.Windows.EventRoute.InvokeHandlersImpl(Object source,
RoutedEventArgs args, Boolean reRaised) at
System.Windows.UIElement.RaiseEventImpl(DependencyObject sender,
RoutedEventArgs args) at
System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at
System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean
trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at
System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport
inputReport) at
System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd,
InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x,
Int32 y, Int32 wheel) at
System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr
hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean&
handled) at
System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at
MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam,
IntPtr lParam, Boolean& handled) at
MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Int32 numArgs) at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object
source, Delegate method, Object args, Int32 numArgs, Delegate
catchHandler) at
System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Int32
numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32
msg, IntPtr wParam, IntPtr lParam) at
MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at
System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame
frame) at
System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run() at
System.Windows.Application.RunDispatcher(Object ignore) at
System.Windows.Application.RunInternal(Window window) at
System.Windows.Application.Run(Window window) at
System.Windows.Application.Run() at Dentist.App.Main() in
D:\development\Dental
Soft\Lotus\AMS\Dentist\obj\x86\Debug\App.g.cs:line 0 at
System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[]
args) at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at
System.Threading.ThreadHelper.ThreadStart_Context(Object state) at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()

Part of the resource dictionary with problem controls

<Border BorderBrush="#A5BFE1" BorderThickness="0,1,1,1" Background="White" Grid.Column="1" Grid.Row="0" >
    <TextBlock x:Name="DayHeader" HorizontalAlignment="Center" VerticalAlignment="Center">
    <TextBlock.ToolTip>
        <ToolTip>
            <StackPanel>
                <TextBlock FontWeight="Bold" Text="{x:Static Properties:Resources.CalendarSelectedDayTitle}" />
                <TextBlock Text="{x:Static Properties:Resources.CalendarSelectedDayDescription}" />
            </StackPanel>
        </ToolTip>
    </TextBlock.ToolTip>
        </TextBlock>
</Border>
<time:Scroll x:Name="scrollViewer" CustomVerticalOffset="640.0" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="60" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <time:TimeRibbon Grid.Column="0"></time:TimeRibbon>
        <time:SchedulerDay Grid.Column="1" x:Name="Day"></time:SchedulerDay>
    </Grid>
</time:Scroll>

Constructor of the Calendar control (that throw exception)

public Calendar()
{
    DefaultStyleKeyProperty.OverrideMetadata(typeof(Calendar), new FrameworkPropertyMetadata(typeof(Calendar)));

    CommandManager.RegisterClassCommandBinding(typeof(Calendar), 
        new CommandBinding(NextDay, new ExecutedRoutedEventHandler(OnExecutedNextDay), 
            new CanExecuteRoutedEventHandler(OnCanExecuteNextDay)));

    CommandManager.RegisterClassCommandBinding(typeof(Calendar),
        new CommandBinding(PreviousDay, new ExecutedRoutedEventHandler(OnExecutedPreviousDay),
            new CanExecuteRoutedEventHandler(OnCanExecutePreviousDay)));
}

But when set in app.xaml the first window MainWindow, not LoginWindow everything works properly without any excetions!

Please advise what can be cause of the problem?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:10:06+00:00Added an answer on June 13, 2026 at 10:10 pm

    The exception is ocurring (as per your screenshot) in your FilterAppointments class constructor. In which you’re performing some actions based on your controltemplate, but the template is not yet assigned in that moment. You should override OnApplyTemplate() and move that code there instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control in WPF. In this I have a DependencyProperty of
I'm trying to use a custom control in a WPF app, and I have
I have a WPF custom control MyControl.cs in my application project (.exe) with its
I am developing a WPF application, and have created a custom control, we will
I have to design a custom chat control, i planned to use 3 basic
I'm going to have to build a custom control for a WinForms application. But
When I create a custom control in WPF and add it to a window,
I am developing a custom WPF control and confused how to use the dependency
I have a C# custom WPF control. I have properties on the control that
I have a custom WPF user control called a TimeoutPanel that I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.