zhanglaoshen 2021-09-04 23:38 采纳率: 66.7%
浏览 119
已结题

wpf DocumentViewer datagrid 鼠标悬停图片上报错

值不能为 null。参数名: current
   at System.Windows.LogicalTreeHelper.GetChildren(DependencyObject current)
   at System.Windows.Documents.FixedPage._CreateChildIndex(DependencyObject e)
   at System.Windows.Documents.FixedTextView.GetTextPositionFromPoint(Point point, Boolean snapToText)
   at MS.Internal.Documents.TextViewBase.System.Windows.Documents.ITextView.GetTextPositionFromPoint(Point point, Boolean snapToText)
   at MS.Internal.Documents.DocumentPageTextView.GetTextPositionFromPoint(Point point, Boolean snapToText)
   at MS.Internal.Documents.MultiPageTextView.GetTextPositionFromPoint(Point point, Boolean snapToText)
   at MS.Internal.Documents.TextViewBase.System.Windows.Documents.ITextView.GetTextPositionFromPoint(Point point, Boolean snapToText)
   at System.Windows.Documents.TextEditorMouse.IsPointWithinInteractiveArea(TextEditor textEditor, Point point)
   at System.Windows.Documents.TextEditorMouse.OnQueryCursor(Object sender, QueryCursorEventArgs e)
   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.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.MouseDevice.UpdateCursorPrivate()
   at System.Windows.Input.MouseDevice.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
   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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, 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 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at WindowsFormsApp1.Program.Main() in C:\Users\ruanbh\Desktop\WindowsFormsApp1\Program.cs:line 18

img

DataTable dt = new DataTable();
dt.Columns.Add("DOCTOR_IMG", typeof(byte[]));
DataRow dr = dt.NewRow();
dr["DOCTOR_IMG"] = File.ReadAllBytes("butterfly.jpg");
dt.Rows.Add(dr);
this.grdGiveDrug.ItemsSource = dt.DefaultView;
<DataGrid Name="grdGiveDrug" HorizontalAlignment="Left" Height="157" Margin="55,83,0,0" VerticalAlignment="Top" Width="334">
            <DataGrid.Columns>
                <!--医生签名-->
                <DataGridTemplateColumn MinWidth="78" Width="*">
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <Border ClipToBounds="True" BorderBrush="Black" BorderThickness="0,0,1,1">
                                <Label Content="医生签名" />
                            </Border>
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Height="23" Width="70" Source="{Binding Path=DOCTOR_IMG}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>


                </DataGrid.Columns>
        </DataGrid>


  • 写回答

2条回答 默认 最新

  • 急速光粒 2021-09-05 08:32
    关注

    没有问题啊!我用你的代码运行后,正常显示,鼠标移动上去也没出现异常。你是不是还有什么代码没贴出来。下面是我运行的结果,鼠标悬浮和选择图片没有出现异常。

    img


    我用的vs2015,debug和release都没有出现问题。
    如有问题,可远程看一下。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
    1人已打赏
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月14日
  • 已采纳回答 9月6日
  • 修改了问题 9月5日
  • 修改了问题 9月5日
  • 展开全部

悬赏问题

  • ¥15 C#字典调用时报错,有关文件加载
  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出
  • ¥30 微信小程序请求失败,网页能正常带锁访问
  • ¥15 Python实现hog特征图可视化
  • ¥30 德飞莱51单片机实现C4炸弹
  • ¥50 CrossLink-LIF-MD6000 型 FPGA 的 CMOS 转 MIPI D-PHY IP 核功能使用异常
  • ¥15 proteus控制16x16LED点阵显示屏的设计