wpfdatagrid

Any Equivalent of DataGridTextColumn.width=“*” for DataGrid rows' height?

徘徊边缘 提交于 2019-12-24 11:53:47
问题 In my understanding, by giving the value " ", a DataGridColumn expands to fill all available margin of a DataGrid . I'd normally specify " " for all the columns to make their widths equal and leave no margin. <DataGrid.Columns> <DataGridTextColumn Header="Header" Width="*"/> <DataGridTextColumn Header="Header" Width="*"/> <DataGridTextColumn Header="Header" Width="*"/> <DataGridTextColumn Header="Header" Width="*"/> <DataGridTextColumn Header="Header" Width="*"/> <DataGridTextColumn Header=

Display datagrid details from the combobox selecteditem

落爺英雄遲暮 提交于 2019-12-24 11:28:36
问题 I have a combobox and a datagrid in my application. The datagrid has its itemsSource from its collectionViewSource and there are three ComboBoxItem 's in the combobox as warning/error/exception as shown in the image below. How to display the selecteditem row details on the datagrid when the respective ComboxBoxitem is selected. this what I have tried. Combobox - XAML <ComboBox SelectedValuePath="{Binding ElementName=dataGrid1,Path=SelectedItem.Type,Mode=OneWay}" Grid.Column="1" Height="32"

DataGrid doesn't deselect hidden items properly when SelectionMode=“Extended”

混江龙づ霸主 提交于 2019-12-24 11:28:33
问题 I have an issue with WPF DataGrid , which drives me crazy. Let's consider this view model: public class ViewModel : INotifyPropertyChanged { public int Id { get; set; } public string Name { get; set; } public bool IsSelected { get { return isSelected; } set { System.Diagnostics.Debug.WriteLine("{0}'s IsSelected new value is: {1}", Name, value); if (isSelected != value) { isSelected = value; OnPropertyChanged("IsSelected"); } } } private bool isSelected; // INPC implementation } ... this XAML:

Using a databound combobox on a datagrid

こ雲淡風輕ζ 提交于 2019-12-24 10:36:37
问题 With a datagrid, I want to use a databound combobox to set the value of a property with the combobox's selected value. How would I go about doing that? Cheers 回答1: This can easily be achieved using the WPF DataGrid's CellTemplate features: <DataGrid.Columns> <DataGridTemplateColumn Header="My Column"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding MyBoundField}"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellEditingTemplate

DataGrid additional column and row

◇◆丶佛笑我妖孽 提交于 2019-12-24 10:13:44
问题 <DataGrid Name="grid" HorizontalAlignment="Left" VerticalAlignment="Top" IsReadOnly="False" HeadersVisibility="None" AutoGenerateColumns="True" AutoGeneratingColumn="c_dataGrid_AutoGeneratingColumn"> public static DataView GetBindable2DArray<T>(this T[,] array) { DataTable dataTable = new DataTable(); for (int i = 0; i < array.GetLength(1); i++) { dataTable.Columns.Add(i.ToString(), typeof(Ref<T>)); } for (int i = 0; i < array.GetLength(0); i++) { DataRow dataRow = dataTable.NewRow();

Label StringFormat doesn't work

[亡魂溺海] 提交于 2019-12-24 09:28:41
问题 I am trying to format a {datetime?} property with stringFormat, but I don't know why it doesn't applied to. this is my code <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid> <Label Content="{Binding From, StringFormat='{}{0:dd.MM.yyyy}'}"/> </Grid> </DataTemplate> </DataGridTemplateColumn.CellTemplate> Am I doing something wrong? 回答1: Put the contents of the label into a TextBlock <Label> <TextBlock Text="{Binding Path=From, StringFormat='{}{0:dd.MM.yyyy}'}"/> </Label> 来源: https:/

Dynamic row and column span in WPF DataGrid

橙三吉。 提交于 2019-12-24 08:27:39
问题 I'm working on a new project where the design calls for dynamic rows and columns displayed in some form of grid. I think I can accomplish this very hackishly using the plain ol' Grid, but it seems like it should be possible using a "real" grid. In my mockup, I circled the tricky bit in red. Under column 1, I have effectively 2 columns of data. The problem is the fact that my data in column 1 can span multiple rows. And the fact that column one is really two pseudo columns and each one can

How to disable Button on validation error

那年仲夏 提交于 2019-12-24 06:10:27
问题 I have a DataGrid like so: <DataGrid CanUserSortColumns="False" CanUserAddRows="True" ItemsSource="{Binding Vertices}" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn x:Name="YColumn" Width="*" Header="Latitude"> <DataGridTextColumn.Binding> <Binding Path="Y"> <Binding.ValidationRules> <validation:DoubleValidationRule /> </Binding.ValidationRules> </Binding> </DataGridTextColumn.Binding> </DataGridTextColumn> <DataGridTextColumn x:Name="XColumn" Width="*" Header="Longitude

DataGrid not scrolling smoothly

喜你入骨 提交于 2019-12-24 04:25:19
问题 I have a DataGrid which usually contains approx 30 rows it rarely goes above 200. My problem is when the user goes through the contents of the grid with the up/down arrow keys it keeps getting stuck(approx 10 to 40 seconds) and then jumping several rows at a time My DataGrid <DataGrid Name="DgInvoiceLines" KeyUp="DgInvoiceLines_KeyUp" BorderBrush="Black" RowBackground="Silver" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" AutoGenerateColumns="False"

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

会有一股神秘感。 提交于 2019-12-24 04:11:13
问题 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