问题标签 [wpftoolkit]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2464 浏览

wpf - WPF DataGrid:获取用于过滤的列绑定属性

我正在尝试为 WPF 开发过滤功能DataGrid(来自 WPF 工具包)。我希望用户右键单击任何单元格并从中选择FilterCcontextMenu然后网格应按单元格的值进行过滤。

我正在尝试 MV-VM 模式。我的 windows 的 datacontext 是MainWindowViewModel具有属性的Transactions。此属性返回ObservableCollection<TransactionViewModel>,并且数据网格使用此集合作为其项目源。所以基本上每一行都是有界的TransactionViewModel(你可以猜到,这个网格列出了交易)。MainWindowsViewModelhasICollectionView用于过滤和跟踪当前选定的行。将DataGrid其属性IsSynchronizedWithCurrentItem设置为“true”,因此myCollectionView.CurrentItem给了我当前选择的TransactionViewModel.

我仍然需要知道的唯一一件事是我需要过滤哪一列。这取决于用户单击上下文菜单的位置。所以我试图使用CommandProperty上下文菜单项传递这些信息。在这里我有一个真正的问题。我试过这个:

这真的很难看,但这适用于DataGridTextColumns。不幸的是,我也有DataGridTemplateColumns,但它们不起作用(那里的路径不同,因为我需要到达实际的单元格模板)...

那么我该如何实现这个功能呢?也许整个方式都是错误的?我没有找到任何有价值的例子。我唯一发现的是 WPFDataGridCodeproject 上的 WPF 自动过滤器实现,由于某种原因它根本不起作用......

谢谢你。

0 投票
1 回答
3462 浏览

wpf - 如何使 WPF Toolkit 的 DataGrid 的模板列可排序?

我的应用程序使用DataGridWPF Toolkit。标准列标题是可点击的(当我用鼠标移动它们时,也会出现一些效果),但模板列的标题没有这种行为。单击标题时不会触发排序事件,也没有视觉效果。

我怎样才能实现排序(或者我需要提供什么信息DataGrid)?

最好的问候,奥利弗·哈纳皮

0 投票
1 回答
3259 浏览

c# - 如何在 C# 中为 WPF 工具包数据网格以编程方式创建列?

我已经看到了很多在 XAML 中创建 WPF 工具包 DataGrid 的示例,并且可以编写某些标签,并且根据您编写的内容会有一些列、行等。

假设我有一个空的(它没有列,没有行,什么都没有)在 XAML 中创建的 WPF Toolkit DataGrid 如何以编程方式在C#中添加列(而不是在 XAML 中)?

感谢您的任何帮助!

0 投票
2 回答
7272 浏览

c# - WPF Toolkit Datagrid - 如何关闭选择?

我在 WPF 中有一个数据网格,我绑定到一个对象。

我在那里有一个 DataGridCheckBoxColumn,我希望用户能够通过并勾选他们想要的那些。问题是他们必须点击两次,一次选择然后再次选中/取消选中。你到底是怎么关掉这个的,我一直在寻找很久才能找到答案的方法。数据网格具有 SelectionMode 和 SelectionUnit 属性——它们都不接受“无”或“离开”

任何帮助表示赞赏!我的代码如下供参考

0 投票
1 回答
2208 浏览

wpf - 按顺序分组?

在 WPF 中,我可以分组,但默认是升序分组。我需要能够控制组的排序(升序或降序)。例如:

第 1 组

  • 项目 1.1
  • 项目 1.2
  • 项目 1.3

第 2 组

  • 第 2.1 项
  • 第 2.2 项

并且还可以切换到:

第 2 组

  • 第 2.1 项
  • 第 2.2 项

第 1 组

  • 项目 1.1
  • 项目 1.2
  • 项目 1.3

    /li>
0 投票
1 回答
11421 浏览

c# - C# WPF 工具包:如何​​使数据网格中的单元格可编辑?

记下这个使用 Microsoft Visual Studio 2008 制作的小型 WPF C# 程序的代码:

.xaml

。CS


这个程序简单地显示了一个 WPF 工具包数据网格,它有 10 列带有标题和一个空行。

选择空行的某个单元格,然后单击编辑时出现问题:程序崩溃。Visual Studio 中出现一个消息框,上面写着:“当前位置没有可用的源代码。” 我想知道如何使数据网格中的单元格可编辑?


这是异常和堆栈跟踪:

System.InvalidOperationException 未处理 Message="'EditItem' 不允许用于此视图。"
来源="演示框架"
StackTrace:在 System.Windows.Controls.ItemCollection.System.ComponentModel.IEditableCollectionView.EditItem(Object item) 在 Microsoft.Windows.Controls.DataGrid.EditRowItem(Object rowItem) 在 C:\dd\WPF_1\src\wpf\src\ ControlsPack\WPFToolkit\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\ 中 Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(ExecutedRoutedEventArgs e) 的第 3396 行DataGrid\Microsoft\Windows\Controls\DataGrid.cs:第 2208 行在 Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(Object sender, ExecutedRoutedEventArgs e) 在 C:\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataGrid \Microsoft\Windows\Controls\DataGrid.cs:System.Windows.Input.CommandBinding.OnExecuted 处的第 2036 行(对象发送者,ExecutedRoutedEventArgs e) 在 System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding) at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute) at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute) at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e) at System.Windows.UIElement.OnExecutedThunk(Object sender , ExecutedRoutedEventArgs e) 在 System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target) 在 System.Windows.RoutedEventArgs。InvokeHandler(委托处理程序,对象目标)在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,RoutedEventArgs routedEventArgs)在 System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs 参数,布尔 reRaised)在 System.Windows.UIElement.RaiseEventImpl( DependencyObject 发送者,RoutedEventArgs 参数)在 System.Windows.UIElement.RaiseEvent(RoutedEventArgs 参数,布尔信任)在 System.Windows.Input.RoutedCommand.ExecuteImpl(对象参数,IInputElement 目标,布尔用户启动)在 System.Windows.Input.RoutedCommand。在 C 中的 Microsoft.Windows.Controls.DataGrid.BeginEdit(RoutedEventArgs editingEventArgs) 处执行(对象参数,IInputElement 目标):\dd\WPF_1\src\wpf\src\ControlsPack\WPFToolkit\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:C:\dd\WPF_1 中 Microsoft.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDown(MouseButtonEventArgs e) 的第 3059 行\src\wpf\src\ControlsPack\WPFToolkit\DataGrid\Microsoft\Windows\Controls\DataGridCell.cs:C:\dd\WPF_1\ 中 Microsoft.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e) 的第 748 行src\wpf\src\ControlsPack\WPFToolkit\DataGrid\Microsoft\Windows\Controls\DataGridCell.cs:System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler 的第 726 行(Delegate genericHandler,Object genericTarget)在 System.Windows.RoutedEventArgs.InvokeHandler( System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target,RoutedEventArgs routedEventArgs) 在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 在 System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) 在 System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender) , MouseButtonEventArgs e) 在 System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e) 在 System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target ) 在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 在 System.Windows。System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trust) 中 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 中的 EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)。 InputManager.ProcessStagingArea() 在 System.Windows.Input.InputManager.ProcessInput(InputEventArgs 输入) 在 System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode 模式, Int32 时间戳,RawMouseActions 动作,Int32 x,Int32 y,Int32 轮)在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,Boolean&处理)在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,Boolean& 处理)在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,Boolean&处理)在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) 在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback , 对象 args, Boolean isSingleParameter, Delegate catchHandler) 在 System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 在 System.Windows.Threading.Dispatcher。InvokeImpl(DispatcherPriority 优先级,TimeSpan 超时,Delegate 方法,Object args,Boolean isSingleParameter)在 System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority 优先级,Delegate 方法,Object arg)在 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() 在 WpfDatagridTest.App.Main() 中 C:\Users\Frank\Documents\Visual_Studio_2008\Projects\WpfDatagridTest\WpfDatagridTest\obj\Debug\App.g.cs: System.AppDomain 的第 0 行。 _nExecuteAssembly(Assembly 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状态)在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态)在 System.Threading.ThreadHelper.ThreadStart() InnerException:\Users\Frank\Documents\Visual_Studio_2008\Projects\WpfDatagridTest\WpfDatagridTest\obj\Debug\App.g.cs:System.AppDomain._nExecuteAssembly 的第 0 行(Assembly 程序集,String[] args)在 System.AppDomain.ExecuteAssembly(String assemblyFile, 证据 assemblySecurity, String[] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(Object state) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object状态)在 System.Threading.ThreadHelper.ThreadStart() InnerException:\Users\Frank\Documents\Visual_Studio_2008\Projects\WpfDatagridTest\WpfDatagridTest\obj\Debug\App.g.cs:System.AppDomain._nExecuteAssembly 的第 0 行(Assembly 程序集,String[] args)在 System.AppDomain.ExecuteAssembly(String assemblyFile, 证据 assemblySecurity, String[] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(Object state) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object状态)在 System.Threading.ThreadHelper.ThreadStart() InnerException: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.Run(ExecutionContext executionContext, ContextCallback回调,对象状态)在 System.Threading.ThreadHelper.ThreadStart() InnerException: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.Run(ExecutionContext executionContext, ContextCallback回调,对象状态)在 System.Threading.ThreadHelper.ThreadStart() InnerException:

0 投票
1 回答
2797 浏览

c# - C# WPF 数据网格:ItemsSource

我想知道一旦设置了 ItemsSource(它是在 XAML 中设置的),您如何修改 WPF 工具包数据网格的列的属性?例如,我想让特定列的属性 IsReadOnly 等于 true。

所以基本上有两件事我想知道:

- 设置 ItemsSource 后如何访问特定列?

- 设置 ItemsSource 后如何更改特定列的属性?

0 投票
2 回答
2641 浏览

c# - C# WPF 数据网格:列数始终等于 0

我在 C# 中创建了一个 WPF takelit 数据网格,并且 ItemsSource 在 XAML 中设置。列是自动生成的。

我正在尝试做一个使用 ObservableCollection 的数据网格,很像这个网站上的内容。

在底部,您会找到一个可以下载的示例(这里是链接

我的问题是我正在尝试更改特定列的某些属性(例如: Datagrid.Columns[index]. Property)但这似乎不起作用,因为列数始终等于 0。因此,我不能使用我要使用的索引更改属性,因为 Columns 集合中似乎没有任何内容。然而在运行时有显示的列。

那么,列数怎么可能等于0呢?

如何在我的情况下更改特定列的属性?

0 投票
2 回答
1473 浏览

c# - 修改数据表

情况:

你好!我正在尝试使用 MS Access 数据库填充 WPF 工具包 DataGrid。

这是我现在拥有的(它有效):

上面的代码示例在 MS Access 数据库的帮助下加载 WPF 工具包 DataGrid。

我想做的是能够在一开始就在 DataGrid 中插入一列。此列将用于写入行号。我认为可以修改变量(这是一个DataTable对象)。


问题:

那么,如何在变量中插入一列,为该新列中的每一行添加行号,并将数据库中的所有数据都保存在 DataGrid 中?

0 投票
5 回答
37404 浏览

wpf - 如何在所有列标题上启用文本换行?

如何在 a 的所有列标题上启用文本换行DataGrid,而不禁用其他默认标题功能?例如需要的列大小调整、排序方向指示符等。

有没有办法做到这一点?