datagrid

Datagrid custom header

你。 提交于 2020-01-05 09:02:27
问题 I want to add an extra row to Datagrid's header row that will contain textboxes (for searching). This row should appear directly under the original header and look like regular item header. This is my code so far: <Window.Resources> <Style x:Key="DataGridColumnHeaderStyle1" TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridColumnHeader}"> <Grid VerticalAlignment="Center" HorizontalAlignment="Stretch"> <Grid

Data grid height is too tall when using word-wrap in text block column

萝らか妹 提交于 2020-01-05 07:49:31
问题 I desire to make data grid with one column representing rather lengthy text values. So my goal functionality is: Column width to be as wide as remaining window space (window can be re-sized) Word-wrap text as necessary Limit data grid height to remaining height of window and provide vertical scroll as necessary The following code meets the first two items and provides a functioning vertical scroll bar, but the data grid height is bizarrely too tall for the content it is showing. Removing word

Data grid height is too tall when using word-wrap in text block column

老子叫甜甜 提交于 2020-01-05 07:49:23
问题 I desire to make data grid with one column representing rather lengthy text values. So my goal functionality is: Column width to be as wide as remaining window space (window can be re-sized) Word-wrap text as necessary Limit data grid height to remaining height of window and provide vertical scroll as necessary The following code meets the first two items and provides a functioning vertical scroll bar, but the data grid height is bizarrely too tall for the content it is showing. Removing word

Data grid height is too tall when using word-wrap in text block column

霸气de小男生 提交于 2020-01-05 07:49:17
问题 I desire to make data grid with one column representing rather lengthy text values. So my goal functionality is: Column width to be as wide as remaining window space (window can be re-sized) Word-wrap text as necessary Limit data grid height to remaining height of window and provide vertical scroll as necessary The following code meets the first two items and provides a functioning vertical scroll bar, but the data grid height is bizarrely too tall for the content it is showing. Removing word

How to Bind Two Lists to Two Columns of Wpf DataGrid?

会有一股神秘感。 提交于 2020-01-05 05:55:34
问题 I want to bind two lists to two columns of a Wpf DataGrid. How is this done in Xaml? Class MainWindow Public Property Column1 As List(Of Integer) = New List(Of Integer) From {1, 2, 3} Public Property Column2 As List(Of Integer) = New List(Of Integer) From {4, 5, 6} End Class 回答1: Zip them : dataGrid1.ItemsSource = Column1 _ .Zip(Column2, _ Function(c1, c2) New With { .Column1 = c1, .Column2 = c2 }) XAML ... <DataGridTextColumn Binding="{Binding Column1}" /> <DataGridTextColumn Binding="

WPF: Set Size of an DataGrid in a Expander

蹲街弑〆低调 提交于 2020-01-05 05:11:34
问题 I have a TabControl which contains a StackPanel with many Expander. In each Expander I placed an UserControl. So, I have a clear view. The UserControl contains a DataGrid. Now, the problem is, that the height from the DataGrid is not set. If the DataGrid is lager than the window-size no Scrollbar is shown. <TabControl SelectionChanged="Selector_OnSelectionChanged" Height="Auto"> <TabItem Header="DoSmth"> </TabItem> <TabItem Header="Misc" Height="Auto"> <StackPanel Height="Auto"> <Expander

Using virtualization for WPF DataGrid inside ScrollViewer

谁说胖子不能爱 提交于 2020-01-05 04:40:41
问题 I know that DataGrid supports virtualization, so it creates grid cells only for visible rows. However, this seems to work only if the DataGrid is constrained in size. In my scenario, a DataGrid is placed inside a scroll-viewer, like so <ScrollViever> <StackPanel> <more elements .../> <DataGrid ... /> <more elements .../> </StackPanel> </ScrollViever> This seems to break virtualization. In cases where the DataGrid should display a large number of items, the visual tree becomes very very large,

Silverlight, datagrid, autogenerated columns on modified column change cell visibility of content

試著忘記壹切 提交于 2020-01-05 04:09:12
问题 I have a form, it has a grid. I autogenerate the columns and tweak them as required: if (e.PropertyName == "id") { System.Windows.Style style = new Style(typeof(DataGridCell)); style.Setters.Add(new Setter(DataGridCell.ContentTemplateProperty, CreateBtnTemplate(30))); e.Column.CellStyle = style; } private static DataTemplate CreateBtnTemplate(int width) { string str = "<DataTemplate xmlns='http://schemas.microsoft.com/client/2007' >" //+ "<Button Tag='{Binding id}' Content='Respond' + "

Refresh WPF Datagrid not bound to observable collection?

点点圈 提交于 2020-01-05 04:09:06
问题 I am using LINQ to SQL with a Datagrid and binding the data to the auto generated fields. The data updates fine when when submitting changes via LINQ. The problem I am having is I cannot seem to refresh the updated data after I run a SQL statement on the database directly. The Databases data is updated correctly and closing down and re-starting the application the data is updated correctly. I have tried, MyTable.Items.Refresh(); And private DatabaseDataContext sql = new DatabaseDataContext(

Wpf DataGrid - Unable to select cells programmatically

两盒软妹~` 提交于 2020-01-05 04:03:58
问题 I need to select all the cells of a column which header was clicked , i took this from the following post : Selecting all Cells in Column when a certain column is clicked i wan't to select all it's respected cells. cs : private void OnColumnsClicked(object sender, RoutedEventArgs e) { var columnHeader = (DataGridColumnHeader)e.OriginalSource; this.AssociatedObject.SelectedCells.Clear(); for (int i = 0; i < this.AssociatedObject.Items.Count; i++) { var cellInfo = new DataGridCellInfo(this