wpfdatagrid

WPF DataGrid Row Header Visibility Error

拟墨画扇 提交于 2019-12-04 02:21:48
I am using a DataGrid to display several fields, one of which is a multi-line description. The grid displays the data just fine until I try to hide the header rows by setting HeadersVisibility="Column" . The header rows disappear but then while I am scrolling the row header reappears for some random rows. I have narrowed it down to the column that displays multi-line description. As long as I leave this column off, then I don't have this issue. I have tried separating the lines by both "\r\n" and "\n" but neither work. Does the DataGrid support multi-line text fields? Below is a picture to

Making a row non-focusable in a WPF datagrid

女生的网名这么多〃 提交于 2019-12-04 01:44:36
问题 I'm trying to figure out how to make the rows in the following WPF DataGrid non-focusable. As you can see I tried adding a <DataGrid.Resources> section to the DataGrid where I'm specifying a DataGrid cell style but this isn't working. What am I missing? <DataGrid Name="grdResources" AutoGenerateColumns="False" SelectionUnit="FullRow" AlternatingRowBackground="LightBlue" CanUserDeleteRows="False" CanUserAddRows="False" CanUserReorderColumns="False" ClipboardCopyMode="ExcludeHeader"> <DataGrid

how to change a row's style in WPF Datagrid?

[亡魂溺海] 提交于 2019-12-03 17:26:42
I am new to WPF, and need help in styling a specific row or rows in a datagrid in runtime, depending on some values of the stored data. I saw this thread but couldn't retrive my problem of row that exist only in runtime from columns that exist in design. any example will be gladly accepted. thanks! edited: I found this thread too, but I need a C# code... I can't tell from your question whether you are adding columns to your grid at run time, but either way you can add a CellStyle to the grid at design time that handles your specific styling needs using DataTriggers. For instance, the following

Disable tabstop between columns in a WPF datagrid

元气小坏坏 提交于 2019-12-03 15:46:34
问题 I have a WPF Toolkit datagrid with mulitple columns. I am trying to get a behaviour where you can tab into the grid using tab, then tab out again using a single tab. E.g. I do not want to tab through all the columns or cells of the grid, just once in, and once out. Is there a simple solution, I have tried setting the TabNavigation to Once, along with disabling TabStop (not shown in code below) and setting TabNavigation on the columns to None, but without success. Is there something I am

DataGrid's CellEditingTemplate and focus in edit mode

南笙酒味 提交于 2019-12-03 15:22:39
问题 I am having an issue with WPFToolkit DataGrid when a column is customized supplying both CellTemplate and CellEditingTemplate . If you take a look below, you will see my editing template has a single CheckBox . All is fine in a functional sense but when F2 is hit to edit the cell, one must also hit TAB in order for the CheckBox to receive focus. Ideally, one would hit F2 and SPACE to toggle the value. Currently, one must hit F2, TAB, SPACE. I have tried setting TabIndex to no avail. I am

Prevent DataGrid Scrolling From Snapping To Rows

强颜欢笑 提交于 2019-12-03 15:15:42
I have a DataGrid in which each row contains an ItemsControl. Because of this, the rows of the grid can be very tall. If a row is taller than the height of the grid, I'm unable to scroll to see the rest of the row because the DataGrid is automatically scrolling to the next row. That is, if I'm viewing the top half of row 1 and I click the vertical scrollbar's down arrow, it skips to the top of row 2. It doesn't let me see the bottom half of row 1. How do I make the DataGrid scroll over rows smoothly instead of stepping row by row? It sound like you want to disable Virtualization. To do it,

Multi-level header GridView WPF

北慕城南 提交于 2019-12-03 12:56:35
I need to set the listview view to a gridview that have a complex header like this (based on a 3 dimensional object list i created): | ---------- LEVEL 0 ------------ | | -- Level 1a -- | -- Level 1b -- | | Lvl A | Lvl B | Lvl A | Lvl B | EDIT: This is more ore less my object model public class Measures { public string Caption { get; set; } public List<Threshold> ThresholdList { get; set; } } public class Threshold { public string Caption { get; set; } public double Value1 { get; set; } public double Value2 { get; set; } public double Value3 { get; set; } public double Value4 { get; set; } } i

How to add horizontal separator in a dynamically created ContextMenu?

南笙酒味 提交于 2019-12-03 11:06:33
问题 I was looking for the solution on the internet but was not able to find it within my sample. I need to add a separator between Context menu item that are generated from code behind. I tried to add it with such code lines like below but without success. this.Commands.Add(new ToolStripSeparator()); I am wondering if someone can help. Thank you in advance. Context Menu XAML: <Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}"> <Setter Property="ContextMenu"> <Setter.Value>

How to add back the sort arrow after applying background of Column headers

梦想与她 提交于 2019-12-03 10:48:08
问题 After applying background color to columnheaders, the sort arrow is missing. How to add it back? 回答1: I think you're gonna have to re-template the DataGridColumnHeader and add it from there. Here's an example. You're gonna have to add a reference to PresentationFramework.Aero xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" <DataGrid ...> <DataGrid.Resources> <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}"> <Setter Property="Width"

WPF Datagrid RowDetailsTemplate visibility bound to a property

孤者浪人 提交于 2019-12-03 06:03:24
I am using a WPF Datagrid with a RowDetails panel where the RowDetailsVisibilityMode is set to "VisibleWhenSelected" and the SelectionMode="Extended" so that multiple rows can be selected and hence display RowDetails, as below: <dg:DataGrid x:Name="MyGrid" ItemsSource="{Binding Path=MyItems}" AutoGenerateColumns="True" SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected"> <dg:DataGrid.RowDetailsTemplate> <DataTemplate> <TextBlock Text="Further Details..."/> </DataTemplate> </dg:DataGrid.RowDetailsTemplate> ... </dg:DataGrid> Unfortunately, for this application it isn't