Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 如何在CalendarItemTemplate中更改DayTitleTemplate的DataTemplate_Wpf_Templates_Xaml_Calendar - Fatal编程技术网

Wpf 如何在CalendarItemTemplate中更改DayTitleTemplate的DataTemplate

Wpf 如何在CalendarItemTemplate中更改DayTitleTemplate的DataTemplate,wpf,templates,xaml,calendar,Wpf,Templates,Xaml,Calendar,当我尝试在日历中更改DayTitleTemplate的默认数据模板时,如果根元素不是文本块,则应用程序崩溃 有人知道如何避免撞车吗 以下是用于演示的模板的简化版本。(Kaxaml就绪) 我有一个类似的问题,下面的帖子帮助了我: 在您的情况下,您将更改: x:Key="{ComponentResourceKey ResourceId=DayTitleTemplate, TypeInTargetAssembly={x:Type CalendarItem}}" 到 您的示例XAML(网格、brown

当我尝试在日历中更改DayTitleTemplate的默认数据模板时,如果根元素不是文本块,则应用程序崩溃

有人知道如何避免撞车吗

以下是用于演示的模板的简化版本。(Kaxaml就绪)


我有一个类似的问题,下面的帖子帮助了我:

在您的情况下,您将更改:

x:Key="{ComponentResourceKey ResourceId=DayTitleTemplate, TypeInTargetAssembly={x:Type CalendarItem}}"


您的示例XAML(网格、brown stroke等)在我使用VS2010 SP1.NET4和x86的机器上不会崩溃。工作正常。您是否碰巧修复了上述异常?如果是这样的话,你能发布解决方案吗?我无法修复它,我不得不使用其他设计。不幸的是,我不能再测试它了,我不再处理这个问题,我的开发环境也不同了。不过我看起来是正确的答案,非常感谢。
System.NullReferenceException はハンドルされませんでした。
  Message=オブジェクト参照がオブジェクト インスタンスに設定されていません。
  Source=PresentationCore
  StackTrace:
       場所 System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
       場所 System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
       場所 System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
       場所 System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       場所 System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       場所 System.Windows.ContextLayoutManager.fireAutomationEvents()
       場所 System.Windows.ContextLayoutManager.UpdateLayout()
       場所 System.Windows.UIElement.UpdateLayout()
       場所 System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
       場所 System.Windows.Interop.HwndSource.LayoutFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       場所 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       場所 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       場所 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       場所 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       場所 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       場所 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       場所 MS.Win32.UnsafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       場所 System.Windows.Window.ShowHelper(Object booleanBox)
       場所 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       場所 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       場所 System.Windows.Threading.DispatcherOperation.InvokeImpl()
       場所 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       場所 System.Threading.ExecutionContext.runTryCode(Object userData)
       場所 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       場所 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       場所 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       場所 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       場所 System.Windows.Threading.DispatcherOperation.Invoke()
       場所 System.Windows.Threading.Dispatcher.ProcessQueue()
       場所 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       場所 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       場所 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       場所 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       場所 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       場所 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       場所 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       場所 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       場所 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       場所 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       場所 System.Windows.Threading.Dispatcher.Run()
       場所 System.Windows.Application.RunDispatcher(Object ignore)
       場所 System.Windows.Application.RunInternal(Window window)
       場所 System.Windows.Application.Run(Window window)
       場所 System.Windows.Application.Run()
  InnerException: 
x:Key="{ComponentResourceKey ResourceId=DayTitleTemplate, TypeInTargetAssembly={x:Type CalendarItem}}"
x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}"