datagridcolumn

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

WPF DataGrid Sync Column Widths

送分小仙女□ 提交于 2019-12-30 01:06:18
问题 I've got two WPF Toolkit DataGrids , I'd like so that when the user resizes the first column in the first grid, it resizes the first column in the second grid. I've tried binding the width of the DataGridColumn in the second grid to the appropriate column in the first grid, but it doesn't work. I'd prefer to use all xaml, but I'm fine with using code behind as well. <tk:DataGrid Width="100" Height="100"> <tk:DataGrid.Columns> <tk:DataGridTextColumn x:Name="Column1" Width="50"/> </tk:DataGrid

Tag Property in WPF DataGrid Column

∥☆過路亽.° 提交于 2019-12-28 18:44:14
问题 I need to save an string inside a Datagrid Column which differs from the Header. This is needed because I generate a Datagrid dynamically and want to translate the Column Headers while generating them. Then I bind the whole XAML to a ContentControl. No problem till here... But I want to reorder and resize the columns, so I need to lookup them afterwoods. For this I need the original (not translated) ColumnHeader. In my opinion a Tag property of the column would solve this problem, but there

How to get DataGridColumnHeader from DataGridColumn?

房东的猫 提交于 2019-12-28 06:56:12
问题 My code is as follows: void mainDataContextObj_CutSelectedColumnEvent(string columnId) { IList<DataGridColumn> columns = dg.Columns; for(int i=2; i<dg.Columns.Count; i++) { DataGridColumnHeader headerObj = dg.Columns[i].Header as DataGridColumnHeader; //This always returns headerObj as null!!! } } I need DataGridColumnHeader from the column. Where am I going wrong? 回答1: The Header object of the DataGridColumn is actually the visible header of that column, whatever you set it to be.

Wpf DataGrid Column splitting

戏子无情 提交于 2019-12-14 03:59:52
问题 I want to put a column to specify range in a wpf datagrid. For this, i am thinking to take one column with header "Range" and i want to split that into 2 columns like "Minimum" and "Maximum". Is it possible to represent data like that? If it is, what about the data binding to the datagrid means how binding will change? 回答1: If you can keep you min/max parts non-resizable, then a fairly simple solution exists: In your objects create a property of Tuple type or whatever type will represent your

How to add an image to a DataGridTemplateColumn header

冷暖自知 提交于 2019-12-11 18:25:01
问题 I have a Datagrid with some DataGridTemplateColumns. One of them is for the costs (see code below). The column heading is Costs. Now I want a image at the right side of the heading Costs. How can I do that? <DataGrid ItemsSource="{Binding AvailableNetworkInterfaces}" SelectedItem="{Binding SelectedItemProperty}"> <DataGrid.Columns> <DataGridTemplateColumn Header="Costs" Width="100" x:Name="ColumnCosts"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Width="80" Text="{Binding

WPF DataGrid Sync Column Widths

时间秒杀一切 提交于 2019-11-30 05:16:44
I've got two WPF Toolkit DataGrids , I'd like so that when the user resizes the first column in the first grid, it resizes the first column in the second grid. I've tried binding the width of the DataGridColumn in the second grid to the appropriate column in the first grid, but it doesn't work. I'd prefer to use all xaml, but I'm fine with using code behind as well. <tk:DataGrid Width="100" Height="100"> <tk:DataGrid.Columns> <tk:DataGridTextColumn x:Name="Column1" Width="50"/> </tk:DataGrid.Columns> </tk:DataGrid> <tk:DataGrid Width="100" Height="100"> <tk:DataGrid.Columns> <tk

Unable to set DataGridColumn's ToolTip

萝らか妹 提交于 2019-11-29 17:37:26
问题 I tried the following: <tk:DataGridTextColumn Header="Item" Binding="{Binding Item.Title}" ToolTipService.ToolTip="{Binding Item.Description}" /> And I don't see any tool tip. Any ideas? Is it even implemented? 回答1: This works for me: <Style TargetType="{x:Type Custom:DataGridColumnHeader}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="ToolTip" Value="{Binding Column.(ToolTipService.ToolTip), RelativeSource={RelativeSource Self}}"/> </Trigger> </Style

WPF - DataGrid Column with Width=“*”, but MinWidth to Fit Contents

时光怂恿深爱的人放手 提交于 2019-11-28 08:04:20
What would be the best/right way to have a set of DataGrid columns have proportional width ( Width="\*"), but to have their minimum width be at least the width of their content? At the moment, if I use Width="*" , then the columns stay exactly proportional, but content gets cropped if the columns get too thin. If I use Width="Auto" , then the columns size themselves perfectly to their content, but this makes them all different sizes. What I want is really a combination of the two, like Width="\*" , MinWidth="Auto" so that when there's extra width the columns will all space out to equal widths,

How to get DataGridColumnHeader from DataGridColumn?

安稳与你 提交于 2019-11-28 01:54:57
My code is as follows: void mainDataContextObj_CutSelectedColumnEvent(string columnId) { IList<DataGridColumn> columns = dg.Columns; for(int i=2; i<dg.Columns.Count; i++) { DataGridColumnHeader headerObj = dg.Columns[i].Header as DataGridColumnHeader; //This always returns headerObj as null!!! } } I need DataGridColumnHeader from the column. Where am I going wrong? The Header object of the DataGridColumn is actually the visible header of that column, whatever you set it to be. DataGridColumn is not part of the Visual Tree so there is not direct way to access the DataGridColumnHeader for it (we