datagridcolumnheader

WPF 4: What happened to DataGridColumnHeader?

无人久伴 提交于 2019-12-23 09:15:05
问题 What happened to DataGridColumnHeader? It looks like it was dropped when the DataGrid was moved into PresentationFramework. 回答1: DataGridColumnHeader is under the System.Windows.Controls.Primitives namespace in the PresentationFramework.dll assembly. 回答2: Something like <DataGrid ItemsSource="{Binding}"> <DataGrid.Columns> <DataGridTextColumn Header="Column Name" Binding="{Binding Name, Mode=TwoWay}" /> </DataGrid.Columns> </DataGrid> 来源: https://stackoverflow.com/questions/2481946/wpf-4-what

DataGridColumnHeader Style

旧巷老猫 提交于 2019-12-13 05:07:42
问题 <Style TargetType="DataGridColumnHeader"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridColumnHeader}"> <Border x:Name="buttonBorderOuter" BorderBrush="#DBDBDB" BorderThickness="1" Background="#00ECECEC" Padding="2"> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> <Border.Triggers>

How to force DataGrid to rebuild VisualTree for its columns

余生长醉 提交于 2019-12-12 03:43:13
问题 I have WPF form with DataGrid. New columns can be added to the datagrid manually by user via button. This is the code to add new column: private void ColumnAdornerAddButton_MouseDown(object sender, MouseButtonEventArgs e) { DataGridTextAdornerColumn column = new DataGridTextAdornerColumn(); column.Header = "New column"; column.HeaderStyle = (Style)FindResource("columnHeader"); column.AdornerTemplate = (DataTemplate)FindResource("columnAdorner"); Binding binding = new Binding("Data"); binding

How to change 'sort glyph icon' color in DataGridView of Windows Form C#?

跟風遠走 提交于 2019-12-11 07:39:12
问题 I've changed the column header color by default. Now, I want to change the 'sort glyph icon' color in DataGridView of Windows Form C# when it gets sorted: See the above picture. The column is sorted but icon's color makes it's visibility inadequate. Please let me know if it's color can be changed. Thanks! 回答1: There is no property for changing color of sort icon. As an option to change it, you can handle CellPainting event and draw the cell yourself. Example private void dgv1_CellPainting

WPF- How to apply LayoutTransform to a specific DataGridColumnHeader

女生的网名这么多〃 提交于 2019-12-11 04:35:15
问题 I have a DataGrid whose ItemsSource is bound to a System.Data.DataTable . This DataTable is filled at runtime with some text columns and some boolean columns. As expected, the text columns are displayed as DataGridTextColumn and the boolean ones are displayed as DataGridCheckBoxColumn . No problem so far. Now I want the column headers of the checkbox columns to be displayed as vertical. So I defined a style like this: <Style x:Key="ColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}"

How can I assign a custom UserControl to a DataGrid column header?

纵饮孤独 提交于 2019-12-10 11:27:56
问题 I am trying to make a datagrid with a custom header that has a textblock and a button. The textblock and button is represented by this UserControl I created: <UserControl x:Class="SilverlightWorkshop.Controls.CollapsibleDataGridHeader" ... /> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding HeaderText, Mode=TwoWay}" /> <Button Content="←" Click="ArrowButtonClick"/> </StackPanel> </UserControl> The idea is, when the user clicks the button, the column width will collapse to a

How can I assign a custom UserControl to a DataGrid column header?

好久不见. 提交于 2019-12-06 12:22:19
I am trying to make a datagrid with a custom header that has a textblock and a button. The textblock and button is represented by this UserControl I created: <UserControl x:Class="SilverlightWorkshop.Controls.CollapsibleDataGridHeader" ... /> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding HeaderText, Mode=TwoWay}" /> <Button Content="←" Click="ArrowButtonClick"/> </StackPanel> </UserControl> The idea is, when the user clicks the button, the column width will collapse to a small size. However, I am having trouble finding an elegant solution for using this control as a template