wpfdatagrid

Lots of unexpected “Cannot retrieve value using the binding” errors

﹥>﹥吖頭↗ 提交于 2019-12-24 04:11:12
问题 When debugging my wpf project I see a lot of binding errors logged in the output window like this one: System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPresenter' (Name=''); target property is 'SelectiveScrollingOrientation' (type 'SelectiveScrollingOrientation') I googled a lot about this kind of message and tried

Initial DataGrid Sorting

北城以北 提交于 2019-12-24 02:58:04
问题 I have a user control that contains a WPF toolkit DataGrid . This control is used in many different places in my app. The grid has no knowledge as to the type of data that will show. Is there a way to initially sort the grid by the first column in ascending order no matter what data the grid is populated with? I don't think I can use a CollectionViewSource because I don't know the PropertyName of the property bound to the first column. 回答1: You could hook to an event: dataGrid

Add combobox to datagrid that is linked to a datable

為{幸葍}努か 提交于 2019-12-24 02:23:54
问题 My program is a WPF application written in VB.net. I accept answers geared toward C# as well, as I should be able to understand and/or convert. I have a dataTable that I fill with data from my MySQL database via MySqlDataAdapter. My dataGrid currently has AutoGenerateColumns="TRUE". I load my dataTable data into my dataGrid by DataGrid1.ItemsSource = MyDataTable.DefaultView In my table I have a column labeled "callType" that I would like to have be a comboBox (DataGridComboBoxColumn) I have

How to keep my selection to the DataGrid Row after refresh the data grid using timer in WPF

两盒软妹~` 提交于 2019-12-24 00:56:46
问题 I have WPF DataGrid and i am binding the DataGrid but if any changes made into the Data it will automatically refresh but my selection to the datagrid row will unselected. 回答1: Instead of using a List to store the data, try using an ObservableCollection . The advantage of using the ObservableCollection is that whenever you add an item to the collection the UI get automatically updated so a manually refresh of the DataGrid is not required. Below I have shared a sample application that adds and

WPF DataGrid EnableColumnVirtualization=“True” Raises NullReferenceException at DataGridCellsPanel.get_HasCorrectRealizedColumns()

人盡茶涼 提交于 2019-12-23 19:23:14
问题 I have a WPF DataGrid with EnableColumnVirtualization="True" . The user control displays but as soon as you scroll or resize you'll receive a NullReferenceException at DataGridCellsPanel.get_HasCorrectRealizedColumns() . Setting ColumnVirtualization="False" corrects the issue. I've tried removing EnableRowVirtualization="True" ... etc thinking that maybe it was due to a combination of properties but I'm able to reproduce the issue with a very simple DataGrid: <DataGrid ItemsSource="{Binding

Accessing the WPF DataGrid “empty” or “rowcolumn” header

房东的猫 提交于 2019-12-23 18:15:01
问题 I am trying to get access to the header that is at the intersection of the rows and columns headers in a Net3.5 WPF DataGrid. Josh Smith calls this the "Empty Header" in an article on a different grid control and I would call it the "RowColumn" header since it in the first position for both the column and row headers and is the only header that is part of both. It defaults to a button with a lower right hand arrow that when you press selects all the items in the DataGrid. I can see this

wpf datagridcheckboxcolumn style

跟風遠走 提交于 2019-12-23 17:02:08
问题 Imagine I have a CheckBox custom style named "MyCheckBoxStyle". How can I make a Datagrid style that embeds a custom DataGridCheckBoxColumn style based on my MyCheckBoxStyle? 回答1: You can use DataGridTemplateColumn to create a custom checkboxcolumn <Custom:DataGridTemplateColumn x:Name="gdchk" Header="Test" MaxWidth="50"> <Custom:DataGridTemplateColumn.CellTemplate > <DataTemplate> <CheckBox IsChecked="{Binding Path = classname}" HorizontalAlignment="Center" Style="{DynamicResource

DataGrid Looses Focus When Delete Key is Pressed

孤街醉人 提交于 2019-12-23 15:28:54
问题 I'm doing MVVM where a DataGrid is bound to an ObservableCollection with a DeleteItemCommand hooked up to the DataGrid.InputBindings as follows: <DataGrid.InputBindings> <KeyBinding Key="Delete" Command="{Binding DeleteItemCommand}" /> </DataGrid.InputBindings> The item and row are removed when the user hits the delete key but the grid looses focus. You have to click or tab to the grid so it regains focus before hitting Delete to remove another row (pretty freaking annoying). I tried setting

Update DataGrid in WPF from another window

試著忘記壹切 提交于 2019-12-23 12:45:51
问题 I have a DataGrid control on a window called MainWindow. From MainWindow i open another window called NewCustomerWindow using the following code on a button click. NewCustomerWindow newCustomerWindow = new NewCustomerWindow(); newCustomerWindow.ShowDialog(); In the NewCustomerWindow i have a form with textboxes where someone can enter information about a customer and then these information are saved into a database. After i save these information i want to update the DataGrid in the

No Parameters are passed to SelectTemplate() of custom DataTemplateSelector. Why?

浪尽此生 提交于 2019-12-23 10:54:17
问题 I'm using a CellTemplateSelector to conditionally display a checkmark in a DataGrid Column. The method SelectTemplate(object item, DependencyObject container) of my DataTemplateSelector class is called but the parameter item is null instead of the expected DataRowView -object. Here is the XAML-Code. Items in Property ItemsSource of DataGrid is a DataTable , which works fine for the other columns. ( I work with Visual Studio Express 2010 ) ... <Window.Resources> <DataTemplate x:Key=