datagrid

WPF: Binding an Element in a DataGridTemplateColumn to an Element in another DataGridTemplateColumn

試著忘記壹切 提交于 2019-12-24 02:12:06
问题 :) I have one DataGrid. In Column2 there is "ComboBox1", in Column3 there is "ComboBox2". I would like to set IsEnabled to false on "ComboBox2" as long as "ComboBox1" has SelectedIndex=0. For each row seperately. This works perfectly outside the Datagrid with two ComboBoxes (with the help of Style and DataTrigger). However, inside the Datagrid, within Column3 I cannot "see" "ComboBox1" ("Cannot find source for binding..."). It's basically a namescope issue. However, referring to a Combobox

how to apply more than one .Tag property in C#?

坚强是说给别人听的谎言 提交于 2019-12-24 01:36:08
问题 when I want to store/pass a value, I always use the .Tag property. for example, when I store the value: Form prosesEdit = new FormProsesChemicalRawWbEdit(); prosesEdit.Tag = (int)this.proses_chemicalDataGridView.Rows[e.RowIndex].Cells[1].Value; prosesEdit.ShowDialog(); Then, I would pass the value into my EDIT form like this: proses_chemical_id = (int) this.Tag; this.proses_chemicalTableAdapter.FillByChemId(this.mcd_softwareDataSet.proses_chemical, proses_chemical_id); this.proses_chemical

C# WPF Datagrid doesn't dynamically sort on data update

旧巷老猫 提交于 2019-12-24 01:27:22
问题 I'm having some trouble with my datagrid : When I update some data (from the model) it shows on my DataGrid, but if click on a header to sort the column it begins to go sideways when I update existing data. Here's 2 1 example s : If I add a new value, it doesn't appear at the end (like it does when I don't sort the datagrid) but it shows at the wrong place (same place every time). If I update an existing value, the order never changes when it needs to do so. I've seen multiple answers but

DataGrid row Background color MVVM

让人想犯罪 __ 提交于 2019-12-24 01:24:09
问题 Im using MVVM architecture and I want to change the row color in a datagrid. The color of row depends on the item from the model. so far I have this Code: private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e) { Log4NetLog dataGridRow = e.Row.DataContext as Log4NetLog; if (highlight) { if (dataGridRow != null) { e.Row.Background = new SolidColorBrush( dataGridRow.LogColour.Colour); } } else { e.Row.Background = new SolidColorBrush(Colors.White); } } As you can see, in the

How can I bind DataGrid row count after a CollectionView filter is applied?

本小妞迷上赌 提交于 2019-12-24 00:52:10
问题 Previously to implementing filtering on the CollectionView, i used this to display the number of rows within the datagrid; <TextBlock Text="{Binding ElementName=dataGrid1, Path=ItemsSource.Count}" /> I have since implemented a filter as so; ICollectionView cvs = CollectionViewSource.GetDefaultView(datagrid1.ItemsSource); cvs.Filter = new Predicate<object>(FilterMethod); ... public bool FilterMethod(object item) { // conditionally returns true/false } The TextBlock above still shows the

WPF DataGrid - Retain selection when disabling

假如想象 提交于 2019-12-24 00:49:35
问题 I have been struggling with this for a while now. I have a Master / Details layout in my application, and am faced, like many others, with the problem of the DataGrid loosing its selection when disabling it. Essencialy, after selecting an element from the list to populate a series of fields, the user presses "Edit", wich disables the DataGrid and enables all of the form's fields. Pressing the "Save" button will revert these actions after saving the data... Pretty strait forward. I am on

Keep selection when refreshing datagrid in ActionScript

喜夏-厌秋 提交于 2019-12-24 00:47:50
问题 I'm working on my first ever AIR application with flashbuilder - just so you know. I've bound a mx:DataGrid component to a DataProvider which is a mx:HTTPService fetching an xml file with items. To keep the data up to data I'm polling the webservice on a given interval. My problem is that I loose the currently selected item in my DataGrid when the data is updated. I've tried to save the DataGrid.selectedIndex and set when the data is updated, but I'm not sure when to do it?! The closest I've

WPF DataGrid icon and boolean value

喜夏-厌秋 提交于 2019-12-24 00:46:38
问题 I have: public class Person { String name { get; set; } String address { get; set; } bool isMarried { get; set; } } My datagrid gets populated with a list of persons. I want to have a custom column where icon-1.jpg is displayed when isMarried is true and icon-2.jpg is displayed when isMarried is false . How do I do this in WPF ? Any ideas ? I know how to do a custom column but I do not know how to assoc the two states of isMarried with icon-1.jpg and icon-2.jpg . 回答1: You could do this with a

DataGrid ComboBox Binding Issue with Selected or New Item

我们两清 提交于 2019-12-24 00:08:59
问题 I am having issue with retaining selected item in a DataGridTemplate column ComboBox. I have the DataTemplate editable combobox column as the first column in the datagrid and next to it, I have a text column. The DataGrid is populated with data read from SQL stored procedure. Everything works fine, except when I select an item in the combobox and move to the text field and start typing in it, the Combo selection blanks out. It blanks out both for a new item or existing item. Oddly, this

WPF DataGrid - add button to end of every row

久未见 提交于 2019-12-23 22:42:55
问题 I'd like to add a button to the end of every row of my datagrid. I've found the following xaml but it adds the button to the start. Anyone know how I can add it after all the databound columns? This adds the button to the start instead of the end: <DataGrid Background ="Black" ItemsSource="{Binding PriceList}"> <DataGrid.Columns> <DataGridTemplateColumn> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button>My button</Button> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <