wpfdatagrid

Changing background color of cells in DataGrid WPF

依然范特西╮ 提交于 2019-12-13 00:36:37
问题 I used the following links to display my 2 dimensional data in a table: How to bind an 2D array bool[][] to a WPF DataGrid (one-way)? Change DataGrid cell colour based on values All is working except that the background color is not changing (and the converter method is not even being hit). Can someone tell me what's going on? Below I post a complete, minimal example. I'm not wedded to any of these ideas (using a DataView to bind my IEnumerable> for example) so feel free to suggest

Edititem is not allowed for this view list

倖福魔咒の 提交于 2019-12-12 21:01:35
问题 I have tried for hours and hours but I cannot edit the column quantity in datagrid, whenever I do it gives me an error saying that An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll Additional information: 'EditItem' is not allowed for this view. My xaml code is <DataGrid EnableRowVirtualization="True" Grid.Row="3" Grid.ColumnSpan="2" AutoGenerateColumns="False" Name="DataGrid1" IsReadOnly="False" ItemsSource="{Binding Products}" Margin="10

WPF Style DataGridHyperlinkColumn

試著忘記壹切 提交于 2019-12-12 20:23:07
问题 I created a style for a hyperlink control: <Style x:Key="MyHyperlink" TargetType="{x:Type Hyperlink}"> <Setter Property="Foreground" Value="{StaticResource HyperlinkBrush}" /> <Setter Property="IsEnabled" Value="{Binding IsEnabled,RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}}" /> <Style.Triggers> <Trigger Property="IsEnabled" Value="True"> <Setter Property="Cursor" Value="Hand"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground"

Issue sorting datagrid

做~自己de王妃 提交于 2019-12-12 18:16:55
问题 A technique I have used for a long time to do sorting in WPF is to create a CollectionViewSource and specifying SortDescriptions, eg <Window.Resources> <CollectionViewSource x:Key="testView"> <CollectionViewSource.SortDescriptions> <cm:SortDescription PropertyName="FirstName" Direction="Descending"></cm:SortDescription> <cm:SortDescription PropertyName="FamilyName"></cm:SortDescription> </CollectionViewSource.SortDescriptions> </CollectionViewSource> This has worked perfectly for everything I

How to lazy-evaluate a wpf:DataGrid, retrieving data only as needed

末鹿安然 提交于 2019-12-12 14:41:24
问题 I have a WPF datagrid, bound to a list populated by linq-to-sql from a database. The binding is two-Way, allowing the user to change the values in each row <wpf:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding MyList}" SelectedItem="{Binding SelectedItem}" > When displaying about 20000 rows, the program crashes with an out-of-memory exception during initialisation of the list. Performance becomes unbearably slow even with less rows. I know that on initialization the datagrid

MVVM DataGrid copy information from selected cells

百般思念 提交于 2019-12-12 14:35:15
问题 I’m using .Net 4.0 DataGrid with MVVM pattern. I need to enable user to select cells and copy information from selected cells to other DataGrid rows (either via keyboard shortcut or context-menu copy/paste). I tried to achieve this via SelectedItem or sending SelectedItem as CommandParameter but this functions only with the whole row and not with cells. (DataGrid is bound to ObservableCollection that contains objects with float fields. These fields are then mapped to DataGrid cells) So, is

Column resizing in wpf datagrid

放肆的年华 提交于 2019-12-12 13:47:27
问题 I am currently developing a WPF software. I am using WPF and am trying to allow the columns to auto size to fit in with the datagrid. I have used columnwidth="*" which works fine as long as the window is not enclosed within scrollview. If it is in a scroll view then the columns resize really big which causes the datagrid to resize wider off the edge of the screen causing a large amount of scrolling. Thanks for any help you can provide. 回答1: You might try binding your scrollviewer's Width to

WPF dataGrid super Header for multiple columns

被刻印的时光 ゝ 提交于 2019-12-12 12:08:46
问题 I want to do Header for multiple columns in WPF DataGrid . I tried with Header template but it will display Header for one column. Below XAML I have tried: <DataGrid> <DataGrid.Columns> <DataGridTextColumn> <DataGridTextColumn.HeaderTemplate> <DataTemplate> <StackPanel> <TextBlock>Column 1</TextBlock> <TextBlock>xyz</TextBlock> </StackPanel> </DataTemplate> </DataGridTextColumn.HeaderTemplate> </DataGridTextColumn> <DataGridTextColumn Header="Header" /> </DataGrid.Columns> </DataGrid> I am

WPF Datagrid Multiple Synchronised Frozen, Collapsable Panes separated by GridSplitter

和自甴很熟 提交于 2019-12-12 11:23:40
问题 I have a requirement to create a "super grid" as part of an application, which will consist of multiple frozen and scrolling panes. The grid also has the requirements that it must support the following features: Display a datagrid with 100s of rows with “reasonable” scrolling performance Group by a certain field, collapse/expand grouped Display any control inside a field, e.g. images, text, combobox, button Allow buttons and editing of fields as well as read-only mode Allow multiple vertical

Show “No record found” message on a WPF DataGrid when it's empty

纵然是瞬间 提交于 2019-12-12 10:13:03
问题 I'm trying to display a "No record found" Message in my WPF Datagrid I tried the solution from the same question here: Show "No record found" message on a WPF DataGrid when it's empty But so far I didn't find a way to add a empty line only when my ObservableCollection is empty. This is the code for my datagrid: <DataGrid DataContext="{Binding RelativeSource={RelativeSource AncestorType=Window}}" ItemsSource="{Binding CameraListObjCode}" AutoGenerateColumns="False" Height="145"