wpfdatagrid

WPF DataGrid Row Header Visibility Error

好久不见. 提交于 2019-12-05 17:12:24
问题 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"

Wpf datagrid validationrule for unique field

試著忘記壹切 提交于 2019-12-05 17:10:57
I've got a suclassed ValidationRule named UniqueNameSolidWoodRule to validate for duplicate entries in a datagrid. Here's the code: public class UniqueNameSolidWoodRule : ValidationRule { public CollectionViewSource CurrentCollection { get; set; } public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if (value != null) { ObservableCollection<SolidWood_VM> castedCollection = (ObservableCollection<SolidWood_VM>)CurrentCollection.Source; foreach (SolidWood_VM swVM in castedCollection) { if (swVM.Designation == value.ToString()) { return new ValidationResult(false,

Binding multifunctional WPF DataGrid

和自甴很熟 提交于 2019-12-05 14:31:16
How would you go about binding a WPF datagrid that needs to display data from many different datasources with varying number of columns with different column headers and types? What I'm currently doing is creating a custom List<DataGridColumn>() list of datagrid columns in my ViewModel for each different collection of records to be displayed in this DataGrid. I Loop over this List to set the DataGrid columns: foreach (DataGridColumn dgc in dgcSample) { dgc.HeaderStyle = hStyle; dgMyDataGrid.Columns.Add(dgc); } Finally, I use the ItemsSource to set the source of items: dgMyDataGrid.ItemsSource

WPF Datagrid flickering issue

霸气de小男生 提交于 2019-12-05 13:49:07
In WPF, I have a DataGrid bound to a DataView in the ViewModel class. It is a touch panel embedded project, so every time I touch and slide my fingers on the panel it keeps sending me values and saves those values to the DataTable and assigns it to the bound DataView in a way where it can show only 5 or 10 rows (predefined) as the data gets updated. Every time I get a new row I delete the last till the total DataTable row count is 5/10. The issue here is that it is taking longer than usual for the DataGrid to bind to the last values. The moment I lift my hand off the panel, I expect the grid

Frozen rows in WPF DataGrid?

穿精又带淫゛_ 提交于 2019-12-05 13:43:58
Does anyone have some code that freezes rows on top in the WPF DataGrid, with Virtualization turned on? We see some code out there without Virtualization off, but we need it with Virtualization on. some links which works only for non-virtualized DataGrid Freeze DataGrid Row scrollable gridview with fixed searched row in datagrid using wpf How does WPF DataGrid get frozen rows/columns working? 来源: https://stackoverflow.com/questions/22731690/frozen-rows-in-wpf-datagrid

does the wpf datagrid have a virtual mode like the winforms DataGridView?

◇◆丶佛笑我妖孽 提交于 2019-12-05 13:43:33
The winforms DataGridView has a virtual model and uses the OnCellValueNeeded method to gets cell values from a a user defined data store. How do i do this in wpf? The DataGrid doesn't seems to have a OnCellValueNeeded method. Thanks Not sure if this already helps you: DataGrid uses UI virtualization , what means that objects are not created before they are visible on screen and the corresponding properties of your source objects will not be called as long as they are not visible. It means also that ui-elements are recycled after they are no more visible. This is for free and you don't have to

WPF Date String Format in XAML [duplicate]

≯℡__Kan透↙ 提交于 2019-12-05 11:39:11
This question already has an answer here: WPF Binding StringFormat Short Date String 7 answers I am trying to format string after a date has been selected by the DatePicker. The Format that I am getting is "9/5/2013 12:00:00 AM" and what I am trying to get is "9/5/2013". Can someone tell me what I am doing wrong with the string format? <DataGridTemplateColumn Header="Start"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Start, StringFormat=d}" FontFamily="Verdana" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn

CellStyle based on RowStyle in WPF

做~自己de王妃 提交于 2019-12-05 11:31:02
I have a WPF DataGrid represented in XAML . I'm using a RowStyle for my grid's TableView but also need to set some properties for specific cells. I need those cells to have the properties of the row style and apply the extra properties from the cell style on top of those. What I would need is something like this, although this doesn't work as it's saying: Target type 'CellContentPresenter' is not convertible to base type 'GridRowContent' <Style x:Key="MyGridRowStyle" BasedOn="{StaticResource {themes:GridRowThemeKey ResourceKey=RowStyle}}" TargetType="{x:Type dxg:GridRowContent}"> <Setter

MvvmLight EventToCommand and WPFToolkit DataGrid double-click

笑着哭i 提交于 2019-12-05 10:55:00
Trying to figure out how to use EventToCommand to set a datagrid double click handler for rows. The command lives in the viewmodel for each row. Just that much out of my experience, since I haven't used interactions yet. Thanks. I would have used mvvmlight tag, but I don't have high enough rep yet to make new tags. This would be the solution if the Command lives on the "GridVieModel" and not on the "RowViewModel". <Window... ...xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns

Spanning a Record Over Multiple Rows in WPF Toolkit's DataGrid

允我心安 提交于 2019-12-05 08:58:08
Is it possible to style WPF Toolkit's DataGrid so a data record can span multiple rows. Example screen shot from a commercial control. Thanks, Ben It is not possible with the toolkit DataGrid or GridView for a ListView, no. However you may have luck with your own implementation, as I recently discovered you can use GridViewHeaderRowPresenter ( MSDN reference ), set the Columns property to the columns you want: that will give you a header row. Then you can use GridViewRowPresenter ( MSDN reference ), attach it to the same Columns collection and voila, your columns in the rows and header will be